Sets the specified event object to the nonsignaled state
#include <WinAPIProc.au3>
_WinAPI_ResetEvent ( $hEvent )
$hEvent | Handle to the event object. The _WinAPI_CreateEvent() function returns this handle. |
Success: | True. |
Failure: | False, call _WinAPI_GetLastError() to get extended error information. |
The state of an event object remains nonsignaled until it is explicitly set to signaled by the _WinAPI_SetEvent() function.
This nonsignaled state blocks the execution of any threads that have specified the event object in a call to one of the _WinAPI_Wait... functions.
The _WinAPI_ResetEvent() function is used primarily for manual-reset event objects, which must be set explicitly to the nonsignaled state.
Auto-reset event objects automatically change from signaled to nonsignaled after a single waiting thread is released.
_WinAPI_CreateEvent, _WinAPI_SetEvent
Search ResetEvent in MSDN Library.
#include <WinAPIHObj.au3>
#include <WinAPIProc.au3>
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)
_WinAPI_ResetEvent($g_tEvents.Event(1))
Case 1
ConsoleWrite("> Second Event" & @CRLF)
_WinAPI_ResetEvent($g_tEvents.Event(2))
Case 2
ConsoleWrite("! Exit Event" & @CRLF)
AdlibUnRegister("_FireEvent_1")
AdlibUnRegister("_FireEvent_2")
_WinAPI_CloseHandle($g_tEvents.Event(1))
_WinAPI_CloseHandle($g_tEvents.Event(2))
_WinAPI_CloseHandle($g_tEvents.Event(3))
ExitLoop
Case -1 ;Error
ExitLoop
EndSwitch
Sleep(10)
WEnd
Func _Exit()
_WinAPI_SetEvent($g_tEvents.Event(3))
EndFunc ;==>_Exit
Func _FireEvent_1()
_WinAPI_SetEvent($g_tEvents.Event(1))
EndFunc ;==>_FireEvent_1
Func _FireEvent_2()
_WinAPI_SetEvent($g_tEvents.Event(2))
EndFunc ;==>_FireEvent_2