title: SendKeys not working/being blocked in my c# application
body: <p>I have an <strong>if</strong> statement in my code which contains a <code>shutdownProcess()</code> method (which uses many, many <code>SendKeys.Send</code> calls) that works perfectly fine when used alone in the <strong>if</strong> statement:</p>
  
  <pre><code>if (waitForRegressionTestToComplete.WaitOne(10*60*1000))
              {
                  shutdownProcess();
              }
  </code></pre>
  
  <p>As I said, this works exactly how I want it to. The <code>SendKeys.Send</code> works as it should, and the process shuts down. However, when I add other items into the if statement, the code enters <code>shutdownProcess()</code> and "sends the keys," but with absolutely no result. The first two keys sent in the method are ALT+TAB x2 in order to regain focus in case it was lost:</p>
  
  <pre><code>SendKeys.Send("%{TAB}");
  SendKeys.Send("%{TAB}");
  </code></pre>
  
  <p>Here is the <strong>if</strong> statement after I have added new items, which causes the problem:</p>
  
  <pre><code>if (waitForRegressionTestToComplete.WaitOne(10*60*1000))
              {
                  shutdownProcess();
  
                  bool processIsStillRunning = true;
  
                  while (processIsStillRunning)
                  {
                      Process[] processlist = Process.GetProcesses();
  
                      processIsStillRunning = false;
                      foreach (Process process in processlist)
                      {
                          if (process.MainWindowTitle.Contains("Process"))
                          {
                              processIsStillRunning = true;
                          }
                      }
                  }
  </code></pre>
  
  <p>The thread also seems to freeze after it has "sent" all of the keys, since it is waiting for the process to exit--to no avail.
  Thanks in advance for your help. I'm completely stumped.</p>