BitSharper.Threading.Helpers.WaitNode.DoWaitUninterruptibly C# (CSharp) Метод

DoWaitUninterruptibly() публичный Метод

public DoWaitUninterruptibly ( IQueuedSync sync ) : void
sync IQueuedSync
Результат void
        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();
                    }
                }
            }
        }

Usage Example

 public override void Lock()
 {
     var caller = Thread.CurrentThread;
     lock (this)
     {
         if (GetHold(caller)) return;
     }
     var n = new WaitNode();
     n.DoWaitUninterruptibly(this);
 }