CommunicationWaitResult CloseCore(TimeSpan timeout, bool aborting)
        {
            ICommunicationWaiter    busyWaiter = null;
            CommunicationWaitResult result     = CommunicationWaitResult.Succeeded;

            lock (this.ThisLock)
            {
                if (this.busyCount > 0)
                {
                    if (this.busyWaiter != null)
                    {
                        if (!aborting && this.aborted)
                        {
                            return(CommunicationWaitResult.Aborted);
                        }
                        busyWaiter = this.busyWaiter;
                    }
                    else
                    {
                        busyWaiter      = new SyncCommunicationWaiter(this.ThisLock);
                        this.busyWaiter = busyWaiter;
                    }
                    Interlocked.Increment(ref busyWaiterCount);
                }
            }

            if (busyWaiter != null)
            {
                result = busyWaiter.Wait(timeout, aborting);
                if (Interlocked.Decrement(ref busyWaiterCount) == 0)
                {
                    busyWaiter.Dispose();
                    this.busyWaiter = null;
                }
            }

            return(result);
        }