protected override void OnAbort()
        {
            IChannel[] channels = SnapshotChannels();
            for (int index = 0; index < channels.Length; index++)
            {
                channels[index].Abort();
            }

            ICommunicationWaiter activityWaiter = null;

            lock (ThisLock)
            {
                if (_activityWaiter != null)
                {
                    activityWaiter = _activityWaiter;
                    Interlocked.Increment(ref _activityWaiterCount);
                }
            }

            if (activityWaiter != null)
            {
                activityWaiter.Signal();
                if (Interlocked.Decrement(ref _activityWaiterCount) == 0)
                {
                    activityWaiter.Dispose();
                    _activityWaiter = null;
                }
            }

            base.OnAbort();
        }
Exemplo n.º 2
0
        protected void DecrementBusyCount()
        {
            ICommunicationWaiter busyWaiter = null;
            bool flag = false;

            lock (this.ThisLock)
            {
                if (this.busyCount <= 0)
                {
                    throw Fx.AssertAndThrow("LifetimeManager.DecrementBusyCount: (this.busyCount > 0)");
                }
                if (--this.busyCount == 0)
                {
                    if (this.busyWaiter != null)
                    {
                        busyWaiter = this.busyWaiter;
                        Interlocked.Increment(ref this.busyWaiterCount);
                    }
                    flag = true;
                }
            }
            if (busyWaiter != null)
            {
                busyWaiter.Signal();
                if (Interlocked.Decrement(ref this.busyWaiterCount) == 0)
                {
                    busyWaiter.Dispose();
                    this.busyWaiter = null;
                }
            }
            if (flag && (this.State == LifetimeState.Opened))
            {
                this.OnEmpty();
            }
        }
        public void DecrementActivityCount()
        {
            ICommunicationWaiter activityWaiter = null;
            bool empty = false;

            lock (ThisLock)
            {
                if (!(ActivityCount > 0))
                {
                    Fx.Assert("ServiceChannelManager.DecrementActivityCount: (this.activityCount > 0)");
                }
                if (--ActivityCount == 0)
                {
                    if (_activityWaiter != null)
                    {
                        activityWaiter = _activityWaiter;
                        Interlocked.Increment(ref _activityWaiterCount);
                    }
                    if (BusyCount == 0)
                    {
                        empty = true;
                    }
                }
            }

            if (activityWaiter != null)
            {
                activityWaiter.Signal();
                if (Interlocked.Decrement(ref _activityWaiterCount) == 0)
                {
                    activityWaiter.Dispose();
                    _activityWaiter = null;
                }
            }

            if (empty && State == LifetimeState.Opened)
            {
                OnEmpty();
            }
        }
Exemplo n.º 4
0
        protected void DecrementBusyCount()
        {
            ICommunicationWaiter busyWaiter = null;
            bool empty = false;

            lock (ThisLock)
            {
                if (BusyCount <= 0)
                {
                    throw Fx.AssertAndThrow("LifetimeManager.DecrementBusyCount: (this.busyCount > 0)");
                }
                if (--BusyCount == 0)
                {
                    if (_busyWaiter != null)
                    {
                        busyWaiter = _busyWaiter;
                        Interlocked.Increment(ref _busyWaiterCount);
                    }
                    empty = true;
                }
            }

            if (busyWaiter != null)
            {
                busyWaiter.Signal();
                if (Interlocked.Decrement(ref _busyWaiterCount) == 0)
                {
                    busyWaiter.Dispose();
                    _busyWaiter = null;
                }
            }

            if (empty && State == LifetimeState.Opened)
            {
                OnEmpty();
            }
        }