public IAsyncResult BeginCloseInput(TimeSpan timeout, AsyncCallback callback, object state) { CloseCommunicationAsyncResult closeResult = null; lock (ThisLock) { if (ActivityCount > 0) { closeResult = new CloseCommunicationAsyncResult(timeout, callback, state, ThisLock); if (!(_activityWaiter == null)) { Fx.Assert("ServiceChannelManager.BeginCloseInput: (this.activityWaiter == null)"); } _activityWaiter = closeResult; Interlocked.Increment(ref _activityWaiterCount); } } if (closeResult != null) { return(closeResult); } else { return(new CompletedAsyncResult(callback, state)); } }
public void EndCloseInput(IAsyncResult result) { if (result is CloseCommunicationAsyncResult) { CloseCommunicationAsyncResult.End(result); if (Interlocked.Decrement(ref _activityWaiterCount) == 0) { _activityWaiter.Dispose(); _activityWaiter = null; } } else { CompletedAsyncResult.End(result); } }
public IAsyncResult BeginCloseInput(TimeSpan timeout, AsyncCallback callback, object state) { CloseCommunicationAsyncResult result = null; lock (base.ThisLock) { if (this.activityCount > 0) { result = new CloseCommunicationAsyncResult(timeout, callback, state, base.ThisLock); ICommunicationWaiter activityWaiter = this.activityWaiter; this.activityWaiter = result; Interlocked.Increment(ref this.activityWaiterCount); } } if (result != null) { return(result); } return(new CompletedAsyncResult(callback, state)); }