Instructs the Process component to wait indefinitely for the associated process to enter an idle state. This is only applicable for processes with a user interface, therefore a message loop.
[Visual Basic] Overloads Public Function WaitForInputIdle() As Boolean [C#] public bool WaitForInputIdle(); [C++] public: bool WaitForInputIdle(); [JScript] public function WaitForInputIdle() : Boolean;
true if the associated process reached an idle state; otherwise, false.
Use WaitForInputIdle to force processing of your application to wait until the message loop has returned to the idle state. When a process with a user interface is executing, its message loop executes every time a windows message is sent to the process by the operating system. The process then returns to the message loop. A process is said to be in an idle state when it is waiting for messages inside of a message loop. This is useful, for example, when your application waits for a starting process to finish creating its main window before communicating with that window.
Note Currently, all processes started using a Process component open in a command window. They contain a message loop and you can set WaitForInputIdle on them meaningfully. This will change in a future release.
If a process does not have a message loop, WaitForInputIdle immediately returns false.
This overload of WaitForInputIdle instructs the Process component to wait indefinitely for the process to become idle in the message loop. This can cause an application to stop responding. For example, if the process is coded to always immediately exits it message loop, as in the code fragment while(true)
.
Process Class | Process Members | System.Diagnostics Namespace | Process.WaitForInputIdle Overload List | Start | CloseMainWindow