title: How to read to end process output asynchronously in C#?
body: <p>I have problem with reading the output of one Process asynchronously in C#. 
  I found some other similar questions on this site but they don't really help me.
  Here is what I do: </p>
  
  <ol>
  <li>Make new process</li>
  <li>Set startinfo
  -FileName, Arguments, CreateNoWindow(true), UseShellExecute(false), RedirectStandardOutput(true)</li>
  <li>Add event handler to OutputDataReceived;</li>
  <li>Start process, BeginOutputReadLine and then WaitForExit().</li>
  </ol>
  
  <p>It works fine but the output of the started process writes some percents(<code>%</code>) which I want to get but I can't since my code reads line by line and the percents don't show up.</p>
  
  <p>Example: </p>
  
  <pre><code>%0,%1...%100
  Finished.
  </code></pre>
  
  <p>My output:</p>
  
  <pre><code>%0
  Finished. 
  </code></pre>
  
  <p>Here is the current code of my program:</p>
  
  <pre><code>StringBuilder sBuilder = new StringBuilder();
  static void proc_OutputDataReceived(object sender, DataReceivedEventArgs e)
  {
      sBuilder.AppendLine(e.Data);
  }
  
  static void CommandExecutor()
  {
      Process process = new Process
      {
          StartInfo = new ProcessStartInfo
          {
              FileName = /*path of the program*/,
              Arguments = /*arguments*/,
              CreateNoWindow = true,
              UseShellExecute = false,
              WindowStyle = ProcessWindowStyle.Hidden,
              RedirectStandardOutput = true
          }
      };
  
      process.OutputDataReceived += new DataReceivedEventHandler(proc_OutputDataReceived);
  
      process.Start();
  
      process.BeginOutputReadLine();
  
      process.WaitForExit();
  }
  </code></pre>