Rediger

Del via


Process.WaitForInputIdle Method

Definition

Causes the Process component to wait for the associated process to enter an idle state.

Overloads

WaitForInputIdle()

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.

WaitForInputIdle(Int32)

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

WaitForInputIdle(TimeSpan)

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

WaitForInputIdle()

Source:
Process.cs
Source:
Process.cs
Source:
Process.cs

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.

public:
 bool WaitForInputIdle();
public bool WaitForInputIdle ();
member this.WaitForInputIdle : unit -> bool
Public Function WaitForInputIdle () As Boolean

Returns

true if the associated process has reached an idle state.

Exceptions

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.

Remarks

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).

See also

Applies to

WaitForInputIdle(Int32)

Source:
Process.cs
Source:
Process.cs
Source:
Process.cs

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

public:
 bool WaitForInputIdle(int milliseconds);
public bool WaitForInputIdle (int milliseconds);
member this.WaitForInputIdle : int -> bool
Public Function WaitForInputIdle (milliseconds As Integer) As Boolean

Parameters

milliseconds
Int32

A value of 1 to Int32.MaxValue that specifies the amount of time, in milliseconds, to wait for the associated process to become idle. A value of 0 specifies an immediate return, and a value of -1 specifies an infinite wait.

Returns

true if the associated process has reached an idle state; otherwise, false.

Exceptions

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.

Remarks

Use WaitForInputIdle(Int32) 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(Int32) throws an InvalidOperationException.

The WaitForInputIdle(Int32) overload instructs the Process component to wait a finite amount of time for the process to become idle in the message loop. If the associated process has not become idle by the end of the interval because the loop is still processing messages, false is returned to the calling procedure.

For more information about handling events, see Handling and Raising Events.

See also

Applies to

WaitForInputIdle(TimeSpan)

Source:
Process.cs
Source:
Process.cs
Source:
Process.cs

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

public:
 bool WaitForInputIdle(TimeSpan timeout);
public bool WaitForInputIdle (TimeSpan timeout);
member this.WaitForInputIdle : TimeSpan -> bool
Public Function WaitForInputIdle (timeout As TimeSpan) As Boolean

Parameters

timeout
TimeSpan

The amount of time, in milliseconds, to wait for the associated process to become idle.

Returns

true if the associated process has reached an idle state; otherwise, false.

Exceptions

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.

Remarks

Use WaitForInputIdle(TimeSpan) 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.

Applies to