Click here to Skip to main content
12,702,969 members (31,972 online)
Rate this:
Please Sign up or sign in to vote.
See more: VC6 C++
What is the purpose of ResetEvent(), While we can complete the task by using CreateEvent(),SetEvent() & WaitForSingleObject() functions?
Posted 29-Jun-11 19:28pm
SAKryukov 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 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 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 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
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170118.1 | Last Updated 30 Jun 2011
Copyright © CodeProject, 1999-2017
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