##// END OF EJS Templates
Reworked cancelation handling, if the cancel handler isn't specified the OperationCanceledException will be handled by the error handler...
Reworked cancelation handling, if the cancel handler isn't specified the OperationCanceledException will be handled by the error handler Any unhandled OperationCanceledException will cause the promise cancelation

File last commit:

r129:471f596b2603 v2
r187:dd4a3590f9c6 ref20160224
Show More
Signal.cs
31 lines | 737 B | text/x-csharp | CSharpLexer
cin
Added Signal class a lightweight alternative to ManualResetEvent
r128 using System;
using System.Threading;
namespace Implab.Parallels {
/// <summary>
cin
Added SharedLock to synchronization routines
r129 /// Implements a simple signalling logic using <see cref="Monitor.PulseAll(object)"/>.
cin
Added Signal class a lightweight alternative to ManualResetEvent
r128 /// </summary>
public class Signal {
readonly object m_lock = new object();
bool m_state;
public void Set() {
lock(m_lock) {
m_state = true;
Monitor.PulseAll(m_lock);
}
}
public void Wait() {
lock (m_lock)
if (!m_state)
Monitor.Wait(m_lock);
}
public bool Wait(int timeout) {
lock (m_lock)
return m_state || Monitor.Wait(m_lock, timeout);
}
}
}