Question: I have the following synchronization problem to solve:

Multiple threads occationally check if a certain condition is fulfilled. If a checking thread finds that the condition is *not* fulfilled, it must block itself until another thread fulfills the condition and thereby releases all waiting/blocked threads.

Does .NET have such an out-of-the-box syncrhonizing class that I can use? Or will I have to build my own synchronization class on top of something else?

What I need is a simple semaphore-like class with only these two methods:

* **bool Wait( TimeSpan maxTimeToWait )** //blocks any caling thread until another thread calls **Signal()** (or timeout - the return value will show what happened)
* **void Signal()** //releases all waiting threads.

Regards, Martin.

Answer: 
[EventWaitHandle](http://msdn.microsoft.com/en-us/library/system.threading.eventwaithandle%28v=vs.110%29.aspx) sounds like what you are looking for. Keep in mind that as you get into such specific implementations, you might be better off making a wrapper class to do what you want by hooking into the disparate .NET classes that do the parts of what you want.

By using an auto-resetting behavior, you can make a handle which is fired every time something about said condition *changes*, and then perform a `while` loop against the condition

```
EventWaitHandle ConditionHandle
//...
while(!condition)
    ConditionHandle.WaitOne();

```
[AutoResetEvent](http://msdn.microsoft.com/en-us/library/system.threading.autoresetevent%28v=vs.110%29.aspx) does what you're asking for.

Ah. I misunderstood what you were asking. A ManualResetEvent or a ManualResetSlim will let all the blocking threads through, but you'll need to reset the MRE to unsignalled manually.