Platform SDK: DLLs, Processes, and Threads |
The WaitForInputIdle function waits until the specified process is waiting for user input with no input pending, or until the time-out interval has elapsed.
DWORD WaitForInputIdle( HANDLE hProcess, // handle to process DWORD dwMilliseconds // time-out interval );
The following table shows the possible return values:
Value | Meaning |
---|---|
0 | The wait was satisfied successfully. |
WAIT_TIMEOUT | The wait was terminated because the time-out interval elapsed. |
-1 | An error occurred. To get extended error information, use the GetLastError function. |
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.
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Requires Windows 95 or later.
Header: Declared in Winuser.h; include Windows.h.
Library: Use User32.lib.
Processes and Threads Overview, Process and Thread Functions, CreateProcess