An Event object is a synchronization object whose state can be explicitly set to signaled.
The event object is useful in sending a signal to a thread indicating that a particular event has occurred. For example, in overlapped input and output, the system sets a specified event object to the signaled state when the overlapped operation has been completed. A single thread can specify different event objects in several simultaneous overlapped operations, then use one of the multiple-object wait functions to wait for the state of any one of the event objects to be signaled.
! demonstrates how to use event and critical section
cs=CreateObject("ACriticalSection")
if cs=Nothing
TestStatus=FAIL
ExitTest
endif
ev=CreateObject("AEvent")
if ev=Nothing
cs=Nothing
TestStatus=FAIL
ExitTest
endif
s=""
hThread=CreateThread(StringConcatThread, 0)
if hThread=0 then
TestStatus=FAIL
ExitTest
endif
! test if thread was completed
if WaitForSingleObject(hThread, 1000)<>awaitObject0
TestStatus=FAIL
endif
! event must be signaled by now
if not ev.Lock(0)
TestStatus=FAIL
endif
cs=Nothing
ev=Nothing