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?
I run into the same issue, but in the context of
Barrier
.Actually If you think about it,
CountdownEvent
is a one phaseBarrier
.So in order to avoide the limitation of:
you may just move on to
Barrier
and use itsAddParticipant
orRemoveParticipan
methods.