Function Reference


Waits until one or all of the specified objects are in the signaled state

#include <WinAPI.au3>
_WinAPI_WaitForMultipleObjects ( $iCount, $paHandles [, $bWaitAll = False [, $iTimeout = -1]] )


$iCount The number of object handles in the array pointed to by $paHandles
$paHandles Pointer to an array of object handles
$bWaitAll [optional] If True, the function returns when the state of all objects in the $paHandles array is signaled.
If False, the function returns when the state of any one of the objects is set to signaled.
In the latter case, the return value indicates the object whose state caused the function to return.
$iTimeout [optional] The time-out interval, in milliseconds.
The function returns if the interval elapses, even if the conditions specified by the $bWaitAll parameter are not met.
If 0, the function tests the states of the specified objects and returns immediately.
If -1, the function's time-out interval never elapses.

Return Value

Success: indicates the event that caused the function to return.
Failure: (-1) WAIT_FAILED, call _WinAPI_GetLastError() to get extended error information.



See Also

Search WaitForMultipleObjects in MSDN Library.


#include <WinAPI.au3>
#include <WinAPIProc.au3> ;needed for _WinAPI_ResetEvent()

Global $g_tEvents = DllStructCreate("handle Event[3];")
$g_tEvents.Event(1) = _WinAPI_CreateEvent(0, True, False)
$g_tEvents.Event(2) = _WinAPI_CreateEvent(0, True, False)
$g_tEvents.Event(3) = _WinAPI_CreateEvent(0, True, False)

HotKeySet("{ESC}", "_Exit")
AdlibRegister("_FireEvent_1", 500)
AdlibRegister("_FireEvent_2", 800)

Local $iEvent
While 1
    $iEvent = _WinAPI_WaitForMultipleObjects(3, $g_tEvents, False, 100)
    Switch $iEvent
        Case 0
            ConsoleWrite("+ First Event" & @CRLF)
        Case 1
            ConsoleWrite("> Second Event" & @CRLF)
        Case 2
            ConsoleWrite("! Exit Event" & @CRLF)
        Case -1 ;Error

Func _Exit()
EndFunc   ;==>_Exit

Func _FireEvent_1()
EndFunc   ;==>_FireEvent_1

Func _FireEvent_2()
EndFunc   ;==>_FireEvent_2