leeeroy
leeeroy

Reputation: 11446

Does SetEvent unblock one or all waiting threads?

If 2 or more threads are waiting on an event, does SetEvent unblock one or all of them(Or some of them) ?

Upvotes: 4

Views: 701

Answers (2)

Jerry Coffin
Jerry Coffin

Reputation: 490573

An auto-reset event will be reset after waking one thread. A manual-reset even will remain set until it's reset, so it can wake up an arbitrary number of threads. It is a bit difficult to know when to reset it if you want to assure that all threads waiting on it wake up exactly once (but then again, if you care about that, it points to a probable design problem).

Upvotes: 3

Mark Wilkins
Mark Wilkins

Reputation: 41252

It depends on if it is a manual or auto-reset event. If it is a manual reset, then multiple threads can be released until it is reset. If it is auto-reset, then only one will be signaled.

Upvotes: 4

Related Questions