title: How to forcibly close Process in c# after some period of time?
body: <p>I got following code</p>
  
  <pre><code>    System.Diagnostics.Process capp = new System.Diagnostics.Process();
      capp.StartInfo.UseShellExecute = false;
      capp.StartInfo.RedirectStandardOutput = true; 
      capp.StartInfo.RedirectStandardError = true;
      capp.EnableRaisingEvents = false;
      capp.StartInfo.FileName = "app.exe";
      capp.StartInfo.Arguments = "-i -v -mj";
      capp.Start();
  
      consoleOutput = capp.StandardOutput.ReadToEnd() + capp.StandardError.ReadToEnd();
      if (!capp.WaitForExit(10000)) capp.Kill(); 
  </code></pre>
  
  <p>and problem, if outside application works correctly it takes less than 10 seconds for it to complete its tasks. If it stop/hung for some reason despite of using</p>
  
  <pre><code>    if (!capp.WaitForExit(10000)) capp.Kill(); 
  </code></pre>
  
  <p>as suggested in some other topic, it keeps working. Above line seem not to work at all in my case, i guess it has to do with fact i read StandardOutput and StandardError. How to fix my code to make reading output and WaitForExit() to work aside?</p>