WaitForInputIdle function (winuser.h)
Waits until the specified process has finished processing its initial input and is waiting for user input with no input pending, or until the time-out interval has elapsed.
DWORD WaitForInputIdle( HANDLE hProcess, DWORD dwMilliseconds );
A handle to the process. If this process is a console application or does not have a message queue, WaitForInputIdle returns immediately.
The time-out interval, in milliseconds. If dwMilliseconds is INFINITE, the function does not return until the process is idle.
The following table shows the possible return values for this function.
||The wait was satisfied successfully.|
||The wait was terminated because the time-out interval elapsed.|
||An error occurred.|
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. If the process has multiple threads, the WaitForInputIdle function returns as soon as any thread becomes idle.
WaitForInputIdle can be used at any time, not just during application startup. However, WaitForInputIdle waits only once for a process to become idle; subsequent WaitForInputIdle calls return immediately, whether the process is idle or busy.
WaitForInputIdle 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 the WaitForInputIdle function to determine when the child's initialization has been completed. For example, the parent process should use the WaitForInputIdle function before trying to find a window associated with the child process.
|Minimum supported client||Windows XP [desktop apps only]|
|Minimum supported server||Windows Server 2003 [desktop apps only]|
|Header||winuser.h (include Windows.h)|
|API set||ext-ms-win-ntuser-misc-l1-1-0 (introduced in Windows 8)|