public virtual void DoWaitUninterruptibly(IQueuedSync sync)
{
lock (this)
{
if (!sync.Recheck(this))
{
var wasInterrupted = false;
while (_waiting)
{
try
{
Monitor.Wait(this);
}
catch (ThreadInterruptedException)
{
wasInterrupted = true;
// no need to notify; if we were signalled, we
// must be not waiting, and we'll act like signalled
}
}
if (wasInterrupted)
{
Thread.CurrentThread.Interrupt();
}
}
}
}