This documentation is archived and is not being maintained.

Process.WaitForInputIdle Method

Updated: July 2009

Causes the Process component to wait indefinitely for the associated process to enter an idle state. This overload applies only to processes with a user interface and, therefore, a message loop.

Namespace:  System.Diagnostics
Assembly:  System (in System.dll)

public bool WaitForInputIdle()

Return Value

Type: System.Boolean
true if the associated process has reached an idle state.

ExceptionCondition
InvalidOperationException

The process does not have a graphical interface.

-or-

An unknown error occurred. The process failed to enter an idle state.

-or-

The process has already exited.

-or-

No process is associated with this Process object.

Use WaitForInputIdle() to force the 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 state is useful, for example, when your application needs to wait for a starting process to finish creating its main window before the application communicates with that window.

If a process does not have a message loop, WaitForInputIdle() throws an InvalidOperationException.

The WaitForInputIdle() overload instructs the Process component to wait indefinitely for the process to become idle in the message loop. This instruction can cause an application to stop responding. For example, if the process is written to always exit its message loop immediately, as in the code fragment while(true).

  • LinkDemand 

    for full trust for the immediate caller. This member cannot be used by partially trusted code.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

Date

History

Reason

July 2009

Added information about how the method throws an exception when there is no message loop.

Customer feedback.

May 2009

Added new exception information.

Customer feedback.

Show: