title: Does process.kill() terminate the WaitForExit() (with no time limit)
body: <p>I have a process that runs in the background and has <code>WaitForExit()</code>, since the duration may vary and I need to wait till it finishes. On occasions, I need to end it before it completes and I trigger <code>.Kill()</code> command via a class event. The <code>.HasExited</code> property changes to true but the code never gets passed the <code>WaitForExit()</code> line.</p>
  
  <pre><code>public class MyProcess: Process
  {
      private bool exited;
  
      public MyProcess()
      {
              ...
      }
  
  
  
  
      public void Start(args...)
      {
  
              try
              {
                  base.StartInfo.FileName = ...
                  base.StartInfo.Arguments = ...
                  base.StartInfo.RedirectStandardOutput = true;
                  base.StartInfo.UseShellExecute = false;
                  base.StartInfo.CreateNoWindow = true;
                  base.EnableRaisingEvents = true;
                  base.Exited += new EventHandler(MyProcessCompleted);
                  base.OutputDataReceived += new DataReceivedEventHandler(outputReceived);
                  base.Start();
                  this.exited = false;
                  base.BeginOutputReadLine();
  
                      while (!this.exited)
                      {
                        if ()
                          {
                         ...
                          }
                         else
                         {
  
                      base.WaitForExit(); ---- after the process is killed, it never gets past this line.
  
                         }
  
                      ...                    
                  }
              }
  
              catch (Exception ex)
              {
                  ...                
               }
          }
  
  
      private void MyProcessCompleted(object sender, System.EventArgs e)
      {
          exited = true;
  
          ...  
      }
  
  
      private void outputReceived(object sender, DataReceivedEventArgs e)
      {
             ...
       }
  
  
    //Subscription to cancel event
      public void ProcessCanceled(object sender, EventArgs e)
      {
          ...
  
          if (!exited)
          {
              base.Kill();
          }
      }
  }
  </code></pre>
  
  <p>\</p>
  
  <p>UPDATE:</p>
  
  <p>My process launches a java based file transfer client and performs a transfer. The process shows up in the task manager and <code>Kill()</code> does not end it. Since I don't really care about ending the process but rather need my program to go to the next "task", I added <code>Close()</code> right after <code>Kill()</code>, which releases the <code>WaitForExit</code> and lets my code "move on". Terminating the process early will be a rare occurance in my app, but I still need it to work, so this implementation will have to do.</p>
  
  <p>}</p>