private bool RemoveAdder(IQueueAdder adder)
        {
            lock (ThisLock)
            {
                if (_closed)
                {
                    return(false);
                }

                bool removed = false;
                for (int i = 0; i < _waitQueue.Count; i++)
                {
                    IQueueAdder current = _waitQueue.Dequeue();

                    if (Object.ReferenceEquals(adder, current))
                    {
                        removed = true;
                    }
                    else
                    {
                        _waitQueue.Enqueue(current);
                    }
                }
                return(removed);
            }
        }
        public void DequeuePending()
        {
            Queue <IQueueAdder> adders = null;

            lock (ThisLock)
            {
                if (_closed || _waitQueue.Count == 0)
                {
                    return;
                }

                int count = Math.Min(_windowSize, QuotaRemaining) - _window.Count;
                if (count <= 0)
                {
                    return;
                }

                count  = Math.Min(count, _waitQueue.Count);
                adders = new Queue <IQueueAdder>(count);

                while (count-- > 0)
                {
                    IQueueAdder adder = _waitQueue.Dequeue();
                    adder.Complete0();
                    adders.Enqueue(adder);
                }
            }

            while (adders.Count > 0)
            {
                adders.Dequeue().Complete1();
            }
        }
        public void DequeuePending()
        {
            Queue <IQueueAdder> queue = null;

            lock (this.ThisLock)
            {
                if (this.closed || (this.waitQueue.Count == 0))
                {
                    return;
                }
                int num = Math.Min(this.windowSize, this.quotaRemaining) - this.window.Count;
                if (num <= 0)
                {
                    return;
                }
                num   = Math.Min(num, this.waitQueue.Count);
                queue = new Queue <IQueueAdder>(num);
                while (num-- > 0)
                {
                    IQueueAdder item = this.waitQueue.Dequeue();
                    item.Complete0();
                    queue.Enqueue(item);
                }
                goto Label_00A6;
            }
Label_009B:
            queue.Dequeue().Complete1();
Label_00A6:
            if (queue.Count > 0)
            {
                goto Label_009B;
            }
        }
 private bool RemoveAdder(IQueueAdder adder)
 {
     lock (this.ThisLock)
     {
         if (this.closed)
         {
             return(false);
         }
         bool flag = false;
         for (int i = 0; i < this.waitQueue.Count; i++)
         {
             IQueueAdder objB = this.waitQueue.Dequeue();
             if (object.ReferenceEquals(adder, objB))
             {
                 flag = true;
             }
             else
             {
                 this.waitQueue.Enqueue(objB);
             }
         }
         return(flag);
     }
 }
 private bool RemoveAdder(IQueueAdder adder)
 {
     lock (this.ThisLock)
     {
         if (this.closed)
         {
             return false;
         }
         bool flag = false;
         for (int i = 0; i < this.waitQueue.Count; i++)
         {
             IQueueAdder objB = this.waitQueue.Dequeue();
             if (object.ReferenceEquals(adder, objB))
             {
                 flag = true;
             }
             else
             {
                 this.waitQueue.Enqueue(objB);
             }
         }
         return flag;
     }
 }
        bool RemoveAdder(IQueueAdder adder)
        {
            lock (this.ThisLock)
            {
                if (this.closed)
                    return false;

                bool removed = false;
                for (int i = 0; i < this.waitQueue.Count; i++)
                {
                    IQueueAdder current = this.waitQueue.Dequeue();

                    if (Object.ReferenceEquals(adder, current))
                        removed = true;
                    else
                        this.waitQueue.Enqueue(current);
                }
                return removed;
            }
        }