Click here to Skip to main content
11,790,387 members (62,599 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: VC6
What is the purpose of ResetEvent(), While we can complete the task by using CreateEvent(),SetEvent() & WaitForSingleObject() functions?
Posted 29-Jun-11 18:28pm
SAKryukov at 1-Jul-11 0:22am
It looks like you thinks you known why using SetEvent.
In this case, I do not understand, how it's possible to not understand why using ResetEvent.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Google is your friend, use it well.[^]

According to MSDN

The 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.
SAKryukov at 1-Jul-11 0:25am
That's correct, my 5.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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
// pseudo code
for(int loop=0;looper<10;looper++)
// add job
// signal a new job is to be done
// and sleep

// do the job we were posted
// then clear the flag and wait again
Chuck O'Toole at 30-Jun-11 1:21am
Microsoft recommends not using PulseEvent().


PulseEvent Function
Sets the specified event object to the signaled state and then resets it to the nonsignaled state after releasing the appropriate number of waiting threads.

Note This function is unreliable and should not be used. It exists mainly for backward compatibility. For more information, see Remarks.
barneyman at 30-Jun-11 1:29am
you learn something new every day - thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 1,114
1 Maciej Los 825
2 KrunalRohit 686
3 CPallini 611
4 ppolymorphe 610

Advertise | Privacy | Mobile
Web03 | 2.8.1509028.1 | Last Updated 30 Jun 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100