I'm trying to use a CountdownEvent to only allow threads to continue when the event's count is zero, however I would like the initial count to be zero. In effect I'd like a return to zero behaviour whereby the event is signalled whenever the count is zero and threads are made to wait whenever it's greater than zero.
I can initialize a Countdown event with 0 initial count but when I try to add to the count I get InvalidOperationException "CountdownEvent_Increment_AlreadyZero" .
Is there an alternative class or another way that I can use Countdown event in order to avoid this limitation?
How about semaphores: http://msdn.microsoft.com/en-us/library/system.threading.semaphore.aspx
Edit: The following post discusses why what you describe is not recommended and also suggests a workaround: http://social.msdn.microsoft.com/Forums/en/parallelextensions/thread/aa49f92c-01a8-4901-9846-91bc1587f3ae