ResetEvent()
is for 'un'
SetEvent()
'ing
In your use case you're obviously using the event singularly, but there are cases where the
WaitForSingleObject()
is within a loop and will be called again, normally in a job workerthread scenario (although
PulseEvent()
may be more appropriate sometimes)
main thread
for(int loop=0;looper<10;looper++)
{
AddJobToWorkerThread();
SetEvent(newJobToBeDoneEvent);
Sleep(10000);
}
workerthread
while(!threadToBeTerminated)
{
if(WaitForSingleObject(newJobToBeDoneEvent,5000)==WAIT_OBJECT_0)
{
...
ResetEvent(newJobToBeDoneEvent);
}
else
break;
}