There's no point using WaitForInputIdle in a loop like that because it waits indefinitely until the process is idle, so it should never return False if the process has a message loop. Accordiong to the help, WaitForInputIdle should return False immediately if the process has no message loop, not throw an exception. It seems that the help may be inaccurate in this case.