Exemplo n.º 1
0
        protected virtual IAsyncResult OnBeginClose(TimeSpan timeout, AsyncCallback callback, object state)
        {
            CloseCommunicationAsyncResult closeResult = null;

            lock (ThisLock)
            {
                if (BusyCount > 0)
                {
                    if (_busyWaiter != null)
                    {
                        Fx.Assert(_aborted, "LifetimeManager.OnBeginClose: (this.aborted == true)");
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ObjectDisposedException(GetType().ToString()));
                    }
                    else
                    {
                        closeResult = new CloseCommunicationAsyncResult(timeout, callback, state, ThisLock);
                        Fx.Assert(_busyWaiter == null, "LifetimeManager.OnBeginClose: (this.busyWaiter == null)");
                        _busyWaiter = closeResult;
                        Interlocked.Increment(ref _busyWaiterCount);
                    }
                }
            }

            if (closeResult != null)
            {
                return(closeResult);
            }
            else
            {
                return(new CompletedAsyncResult(callback, state));
            }
        }
Exemplo n.º 2
0
 protected virtual void OnEndClose(IAsyncResult result)
 {
     if (result is CloseCommunicationAsyncResult)
     {
         CloseCommunicationAsyncResult.End(result);
         if (Interlocked.Decrement(ref _busyWaiterCount) == 0)
         {
             _busyWaiter.Dispose();
             _busyWaiter = null;
         }
     }
     else
     {
         CompletedAsyncResult.End(result);
     }
 }
Exemplo n.º 3
0
        protected virtual IAsyncResult OnBeginClose(TimeSpan timeout, AsyncCallback callback, object state)
        {
            CloseCommunicationAsyncResult result = null;

            lock (this.ThisLock)
            {
                if (this.busyCount > 0)
                {
                    if (this.busyWaiter != null)
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ObjectDisposedException(base.GetType().ToString()));
                    }
                    result          = new CloseCommunicationAsyncResult(timeout, callback, state, this.ThisLock);
                    this.busyWaiter = result;
                    Interlocked.Increment(ref this.busyWaiterCount);
                }
            }
            if (result != null)
            {
                return(result);
            }
            return(new CompletedAsyncResult(callback, state));
        }
Exemplo n.º 4
0
        private static void TimeoutCallback(object state)
        {
            CloseCommunicationAsyncResult closeResult = (CloseCommunicationAsyncResult)state;

            closeResult.Timeout();
        }
Exemplo n.º 5
0
        protected virtual IAsyncResult OnBeginClose(TimeSpan timeout, AsyncCallback callback, object state)
        {
            CloseCommunicationAsyncResult closeResult = null;

            lock (this.ThisLock)
            {
                if (_busyCount > 0)
                {
                    if (_busyWaiter != null)
                    {
                        Fx.Assert(_aborted, "LifetimeManager.OnBeginClose: (this.aborted == true)");
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ObjectDisposedException(this.GetType().ToString()));
                    }
                    else
                    {
                        closeResult = new CloseCommunicationAsyncResult(timeout, callback, state, this.ThisLock);
                        Fx.Assert(_busyWaiter == null, "LifetimeManager.OnBeginClose: (this.busyWaiter == null)");
                        _busyWaiter = closeResult;
                        Interlocked.Increment(ref _busyWaiterCount);
                    }
                }
            }

            if (closeResult != null)
            {
                return closeResult;
            }
            else
            {
                return new CompletedAsyncResult(callback, state);
            }
        }
 protected virtual IAsyncResult OnBeginClose(TimeSpan timeout, AsyncCallback callback, object state)
 {
     CloseCommunicationAsyncResult result = null;
     lock (this.ThisLock)
     {
         if (this.busyCount > 0)
         {
             if (this.busyWaiter != null)
             {
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ObjectDisposedException(base.GetType().ToString()));
             }
             result = new CloseCommunicationAsyncResult(timeout, callback, state, this.ThisLock);
             this.busyWaiter = result;
             Interlocked.Increment(ref this.busyWaiterCount);
         }
     }
     if (result != null)
     {
         return result;
     }
     return new CompletedAsyncResult(callback, state);
 }