Why doesn't Process.WaitForInputIdle() work?
===

I am using Windows Automation to test my UI and am opening and closing processes.  I want to have a valid WindowHandle, but Process.WaitForInputIdle() doesn't wait long enough.  I have a work around, but don't understand why WaitForInputIdle() doesn't work.

Below is a small code snip:


    Process = new Process
                  {
                     StartInfo =
                     {
                         WorkingDirectory = directory,
                         FileName = EXECUTABLE_FILE_NAME
                     }
                  };
    
    Process.Start();
    
    //Process.WaitForInputIdle() doesn't work, 
    //so will use a while loop until MainWindowHandle isn't IntPtr.Zero anymore,
    //or until 10 seconds have elapsed
    
    int count = 0;
    
    while (Process.MainWindowHandle == IntPtr.Zero && count<100)
    {
        count++;
        Thread.Sleep(100);
    }
    
    AppElement = AutomationElement.FromHandle(Process.MainWindowHandle);

