title: Realtime Console Output Redirection using Process
body: <p>I am using VBOXMANAGE to "export" a guest machine. VBOXManage is a Console application that can control the guest machine's behavior from the host. Since the export command is a long process, it returns process updates like so:</p>
  
  <p>0%...10%...20%...30%...100%</p>
  
  <p>I am writing a C# application that will invoke VBOXManage using Process. Here's my code:</p>
  
  <pre><code>Process VBOXProc = new Process();
  
  VBOXProc.StartInfo.FileName = VBOXMANAGE;
  VBOXProc.StartInfo.Arguments = Arguments;
  VBOXProc.StartInfo.UseShellExecute = false;
  VBOXProc.StartInfo.CreateNoWindow = true;
  VBOXProc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
  VBOXProc.StartInfo.RedirectStandardError = true;
  VBOXProc.StartInfo.RedirectStandardOutput = true;
  
  VBOXProc.OutputDataReceived += new DataReceivedEventHandler(VBOXProc_OutputDataReceived);
  VBOXProc.ErrorDataReceived += new DataReceivedEventHandler(VBOXProc_ErrorDataReceived);
  
  VBOXProc.EnableRaisingEvents = true;
  
  VBOXProc.Start();
  VBOXProc.BeginOutputReadLine();
  VBOXProc.BeginErrorReadLine();
  
  VBOXProc.WaitForExit();
  </code></pre>
  
  <p>This is fine, except that the output is being read per LINE. This means that the process updates "
  0%...10%...20%...30%...100%" will only show AFTER the actual process is done.</p>
  
  <p>Is there a way to capture the console output in realtime?</p>
  
  <p>Thanks!</p>