WaitForSingleObjectEx

The WaitForSingleObjectEx function waits until the specified object is in the signaled state or the time-out interval elapses.

Syntax

DWORD WaitForSingleObjectEx(
    HANDLE hHandle,
    DWORD dwMilliseconds,	
    BOOL bAlertable

);

NOTE: The signatures for WaitForSingleObjectEx and RtWaitForSingleObjectEx are different but will result in the same behavior when used in a real-time application.

Parameters

hHandle

A handle to the object. For a list of the object types whose handles can be specified, see the following Remarks section.

If this handle is closed while the wait is still pending, the function's behavior is undefined.

dwMilliseconds

The time-out interval, in milliseconds. If a nonzero value is specified, the function waits until the object is signaled or the interval elapses. If dwMilliseconds is zero, the function does not enter a wait state. If the object is not signaled; it always returns immediately. If dwMilliseconds is INFINITE, the function will wait indefinitely until the object is signaled.

bAlertable

If this parameter is TRUE and the thread is in the waiting state, the function returns when the system queues an I/O completion routine or APC, and the thread runs the routine or function. Otherwise, the function does not return, and the completion routine or APC function is not executed.

NOTE: The RTX64 implementation of WaitForSingleObjectEx will always ignore the bAlertable parameter.

Return Value

To get extended error information, call GetLastError.

The return value indicates the event that caused the function to return. It can be one of the following values.

Value Meaning

WAIT_ABANDONED

0x00000080L

The specified object is a mutex object that was not released by the thread that owned the mutex object before the owning thread terminated. Ownership of the mutex object is granted to the calling thread and the mutex state is set to nonsignaled.

If the mutex was protecting persistent state information, you should check it for consistency.

WAIT_OBJECT_0

0x00000000L

The state of the specified object is signaled.

WAIT_TIMEOUT

0x00000102L

The time-out interval elapsed, and the object's state is nonsignaled.

WAIT_FAILED (DWORD)

0xFFFFFFFF

The function has failed. To get extended error information, call GetLastError.

NOTE: The RTX64 implementation of WaitForSingleObjectEx differs from the standard Windows implementation in that it will always ignore the bAlertable parameter. Because of this, the value WAIT_IO_COMPLETION will never be returned. For more information, please see the following link: https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-waitforsingleobjectex

Remarks

The WaitForSingleObjectEx function determines whether the wait criteria have been met. If the criteria have not been met, the calling thread enters the wait state until the conditions of the wait criteria have been met or the time-out interval elapses.

The function modifies the state of some types of synchronization objects. Modification occurs only for the object whose signaled state caused the function to return.

The WaitForSingleObjectEx function can wait for the following objects:

Requirements

Minimum Supported Version RTX64 2013
Header windows.h
Library Rtx_Rtss.lib

See Also:

WaitForSingleObject

RtWaitForSingleObjectEx