title: Redirect Standard Output Efficiently in .NET
body: <p>I am trying to call php-cgi.exe from a .NET program. I use RedirectStandardOutput to get the output back as a stream but the whole thing is very slow.</p>
  
  <p>Do you have any idea on how I can make that faster? Any other technique?</p>
  
  <pre><code>    Dim oCGI As ProcessStartInfo = New ProcessStartInfo()
      oCGI.WorkingDirectory = "C:\Program Files\Application\php"
      oCGI.FileName = "php-cgi.exe"
      oCGI.RedirectStandardOutput = True
      oCGI.RedirectStandardInput = True
      oCGI.UseShellExecute = False
      oCGI.CreateNoWindow = True
  
      Dim oProcess As Process = New Process()
  
      oProcess.StartInfo = oCGI
      oProcess.Start()
  
      oProcess.StandardOutput.ReadToEnd()
  </code></pre>