title: Reading output from another running application
body: <p>I'm working on a custom IDE in C# for a scripting language, and I have a problem.</p>
  
  <p>I'm trying to start the compiler process (pawncc.exe) and pass arguments to it. I've done that, and now I have a problem. When I want to display the output from the compiler application, it only displays some parts of it. It should output this (<strong>got this from the command prompt</strong>):</p>
  
  <pre><code>Pawn compiler 3.2.3664                  Copyright (c) 1997-2006, ITB CompuPhase
  
  newGM.pwn(0) : fatal error 100: cannot read from file: "includes/main_include.inc"
  
  Compilation aborted.
  1 Error.
  </code></pre>
  
  <p>But it doesn't. It outputs this (<strong>in the application, using the same command/arguments</strong>):</p>
  
  <pre><code>Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase
  
  
  1 Error.
  </code></pre>
  
  <p>I just don't get it! It's a really weird thing. It might be something simple but I've been looking at it, and researching for hours now! Here's my code:</p>
  
  <pre><code>        public Form3(string path)
          {
              InitializeComponent();
  
              this._path = path;
  
              Process myProcess = new Process();
              ProcessStartInfo startInfo = new ProcessStartInfo("pawncc.exe");
              startInfo.CreateNoWindow = true;
              startInfo.UseShellExecute = false;
              startInfo.RedirectStandardOutput = true;
              startInfo.Arguments = path + " -r -d2";
              myProcess.StartInfo = startInfo;
              myProcess.Start();
  
              while (true)
              {
                  string myString;
                  byte[] buffer = new byte[512];
                  var ar = myProcess.StandardOutput.BaseStream.BeginRead(buffer, 0, 512, null, null);
                  ar.AsyncWaitHandle.WaitOne();
                  var bytesRead = myProcess.StandardOutput.BaseStream.EndRead(ar);
                  if (bytesRead &gt; 0)
                  {
                      myString = Encoding.ASCII.GetString(buffer, 0, bytesRead);
                  }
                  else
                  {
                      myProcess.WaitForExit();
                      break;
                  }
                  richTextBox1.Text = myString;
  
              }
  
          }
  </code></pre>
  
  <p><strong>!!EDIT:</strong></p>
  
  <p>It does the same thing with this code:</p>
  
  <pre><code>        public Form3(string path)
          {
              InitializeComponent();
  
              this._path = path;
  
              Process myProcess = new Process();
              ProcessStartInfo startInfo = new ProcessStartInfo("pawncc.exe");
              startInfo.CreateNoWindow = true;
              startInfo.UseShellExecute = false;
              startInfo.RedirectStandardOutput = true;
              startInfo.RedirectStandardError = true;
              startInfo.Arguments = path + " -r -d2";
              myProcess.StartInfo = startInfo;
              myProcess.Start();
  
              using (StreamReader reader = myProcess.StandardOutput)
              {
                  string result = reader.ReadToEnd();
                  richTextBox1.Text = result;
              }
          }
  </code></pre>