private CommunicationWaitResult CloseCore(TimeSpan timeout, bool aborting) { ICommunicationWaiter busyWaiter = null; CommunicationWaitResult result = CommunicationWaitResult.Succeeded; lock (ThisLock) { if (BusyCount > 0) { if (_busyWaiter != null) { if (!aborting && _aborted) { return(CommunicationWaitResult.Aborted); } busyWaiter = _busyWaiter; } else { busyWaiter = new SyncCommunicationWaiter(ThisLock); _busyWaiter = busyWaiter; } Interlocked.Increment(ref _busyWaiterCount); } } if (busyWaiter != null) { result = busyWaiter.Wait(timeout, aborting); if (Interlocked.Decrement(ref _busyWaiterCount) == 0) { busyWaiter.Dispose(); _busyWaiter = null; } } return(result); }
private CommunicationWaitResult CloseCore(TimeSpan timeout, bool aborting) { ICommunicationWaiter busyWaiter = null; CommunicationWaitResult result = CommunicationWaitResult.Succeeded; lock (this.ThisLock) { if (_busyCount > 0) { if (_busyWaiter != null) { if (!aborting && _aborted) return CommunicationWaitResult.Aborted; busyWaiter = _busyWaiter; } else { busyWaiter = new SyncCommunicationWaiter(this.ThisLock); _busyWaiter = busyWaiter; } Interlocked.Increment(ref _busyWaiterCount); } } if (busyWaiter != null) { result = busyWaiter.Wait(timeout, aborting); if (Interlocked.Decrement(ref _busyWaiterCount) == 0) { busyWaiter.Dispose(); _busyWaiter = null; } } return result; }