Ejemplo n.º 1
0
 public void IncrementOperationCount(long count)
 {
     lock (this.syncLock)
     {
         if (this.rejectNewRequests)
         {
             throw new OperationCanceledException("Object is in the process of idling");
         }
         PendingOperationTracker pendingOperationTracker = this;
         pendingOperationTracker.pendingOperationCount = pendingOperationTracker.pendingOperationCount + count;
     }
 }
Ejemplo n.º 2
0
            public WaitPendingOperationsAsyncResult(PendingOperationTracker owner, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state)
            {
                this.owner   = owner;
                this.timeout = timeout;
                AsyncWaiter asyncWaiter = null;

                lock (this.owner.syncLock)
                {
                    this.owner.rejectNewRequests = true;
                    if (this.owner.pendingOperationCount > (long)0)
                    {
                        asyncWaiter = new AsyncWaiter(timeout, PendingOperationTracker.WaitPendingOperationsAsyncResult.StaticOnWaiterCompleted, this);
                        this.owner.waiters.Add(asyncWaiter);
                    }
                }
                if (asyncWaiter == null)
                {
                    base.Complete(true);
                }
            }
Ejemplo n.º 3
0
        private void DecrementOperationCount(long count)
        {
            List <AsyncWaiter> asyncWaiters = null;

            lock (this.syncLock)
            {
                PendingOperationTracker pendingOperationTracker = this;
                pendingOperationTracker.pendingOperationCount = pendingOperationTracker.pendingOperationCount - count;
                if (this.waiters.Count != 0)
                {
                    asyncWaiters = new List <AsyncWaiter>(this.waiters);
                    this.waiters.Clear();
                }
            }
            if (asyncWaiters != null)
            {
                foreach (AsyncWaiter asyncWaiter in asyncWaiters)
                {
                    asyncWaiter.Signal();
                }
            }
        }