Click to Rate and Give Feedback
MSDN
MSDN Library
System Services
 WaitForInputIdle Function
WaitForInputIdle Function

Waits until the specified process is waiting for user input with no input pending, or until the time-out interval has elapsed.

Syntax

DWORD WINAPI WaitForInputIdle(
  __in  HANDLE hProcess,
  __in  DWORD dwMilliseconds
);

Parameters

hProcess [in]

A handle to the process. If this process is a console application or does not have a message queue, WaitForInputIdle returns immediately.

dwMilliseconds [in]

The time-out interval, in milliseconds. If dwMilliseconds is INFINITE, the function does not return until the process is idle.

Return Value

The following table shows the possible return values for this function.

Return code/valueDescription

0

The wait was satisfied successfully.

WAIT_TIMEOUT

The wait was terminated because the time-out interval elapsed.

WAIT_FAILED

An error occurred.

Remarks

The WaitForInputIdle function enables a thread to suspend its execution until the specified process has finished its initialization and is waiting for user input with no input pending. This can be useful for synchronizing a parent process and a newly created child process. When a parent process creates a child process, the CreateProcess function returns without waiting for the child process to finish its initialization. Before trying to communicate with the child process, the parent process can use WaitForInputIdle to determine when the child's initialization has been completed. For example, the parent process should use WaitForInputIdle before trying to find a window associated with the child process.

The WaitForInputIdle function can be used at any time, not just during application startup.

Requirements

Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinuser.h (include Windows.h)
LibraryUser32.lib
DLLUser32.dll

See Also

CreateProcess
Process and Thread Functions
Synchronizing Execution of Multiple Threads


Send comments about this topic to Microsoft

Build date: 11/6/2008

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
.NET users should use Process.WaitForInputIdle      David M. Kean - MSFT ... JizzleB   |   Edit   |  

.NET Framework users should look at using Process.WaitForInputIdle which is the managed equivalent of this function

Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker