コード例 #1
0
 public void Abort()
 {
     lock (this.ThisLock)
     {
         if (!this.aborted)
         {
             this.aborted = true;
             if (this.waiters != null)
             {
                 while (this.waiters.Count > 0)
                 {
                     AsyncWaitHandle asyncWaitHandle = this.waiters.Dequeue();
                     asyncWaitHandle.Set();
                 }
             }
         }
     }
 }
コード例 #2
0
        // Abort the ThreadNeutralSemaphore object.
        public void Abort()
        {
            lock (this.ThisLock)
            {
                if (this.aborted)
                {
                    return;
                }

                this.aborted = true;

                if (this.waiters != null)
                {
                    while (this.waiters.Count > 0)
                    {
                        AsyncWaitHandle waiter = this.waiters.Dequeue();
                        waiter.Set();
                    }
                }
            }
        }
コード例 #3
0
        public int Exit()
        {
            int num;
            int num1 = -1;

            lock (this.ThisLock)
            {
                if (!this.aborted)
                {
                    if (this.count != 0)
                    {
                        if (this.waiters == null || this.waiters.Count == 0)
                        {
                            ThreadNeutralSemaphore threadNeutralSemaphore = this;
                            threadNeutralSemaphore.count = threadNeutralSemaphore.count - 1;
                            num = this.count;
                        }
                        else
                        {
                            AsyncWaitHandle asyncWaitHandle = this.waiters.Dequeue();
                            num1 = this.count;
                            asyncWaitHandle.Set();
                            return(num1);
                        }
                    }
                    else
                    {
                        string invalidSemaphoreExit = InternalSR.InvalidSemaphoreExit;
                        throw Fx.Exception.AsError(new SynchronizationLockException(invalidSemaphoreExit));
                    }
                }
                else
                {
                    num = num1;
                }
            }
            return(num);
        }