Esempio n. 1
0
 public void Exit()
 {
     AsyncSemaphore.SemaphoreWaiter value = null;
     lock (this.SyncRoot)
     {
         if (this.count == this.maximumCount)
         {
             throw new SemaphoreFullException(SRCore.AsyncSemaphoreExitCalledWithoutEnter);
         }
         if (this.waiters.Count <= 0)
         {
             AsyncSemaphore asyncSemaphore = this;
             asyncSemaphore.count = asyncSemaphore.count + 1;
         }
         else
         {
             LinkedListNode <AsyncSemaphore.SemaphoreWaiter> first = this.waiters.First;
             this.waiters.Remove(first);
             value = first.Value;
         }
     }
     if (value != null)
     {
         value.Signal(false, true);
     }
 }
Esempio n. 2
0
        private void HandleTimeout(AsyncSemaphore.SemaphoreWaiter waiter)
        {
            bool flag = false;

            lock (this.SyncRoot)
            {
                if (waiter.Node.List != null)
                {
                    flag = true;
                    this.waiters.Remove(waiter.Node);
                }
            }
            if (flag)
            {
                waiter.Signal(false, false);
            }
        }