public CloseAsyncResult(ConnectionOrientedTransportChannelFactory <TChannel> parent, TimeSpan timeout,
                                    AsyncCallback callback, object state)
                : base(callback, state)
            {
                this.parent        = parent;
                this.timeoutHelper = new TimeoutHelper(timeout);

                this.parent.GetUpgradeAndConnectionPool(out this.upgradeProvider, out this.connectionPool);

                if (this.connectionPool == null)
                {
                    if (this.HandleReleaseConnectionPoolComplete())
                    {
                        this.Complete(true);
                    }
                }
                else
                {
                    if (onReleaseConnectionPoolScheduled == null)
                    {
                        onReleaseConnectionPoolScheduled = new Action <object>(OnReleaseConnectionPoolScheduled);
                    }
                    ActionItem.Schedule(onReleaseConnectionPoolScheduled, this);
                }
            }
 private static void OnOpenComplete(IAsyncResult result)
 {
     if (!result.CompletedSynchronously)
     {
         ConnectionOrientedTransportChannelFactory <TChannel> .OpenAsyncResult asyncState = (ConnectionOrientedTransportChannelFactory <TChannel> .OpenAsyncResult)result.AsyncState;
         Exception exception = null;
         try
         {
             asyncState.communicationObject.EndOpen(result);
         }
         catch (Exception exception2)
         {
             if (Fx.IsFatal(exception2))
             {
                 throw;
             }
             exception = exception2;
         }
         asyncState.Complete(false, exception);
     }
 }
            private static void OnReleaseConnectionPoolScheduled(object state)
            {
                bool flag;

                ConnectionOrientedTransportChannelFactory <TChannel> .CloseAsyncResult result = (ConnectionOrientedTransportChannelFactory <TChannel> .CloseAsyncResult)state;
                Exception exception = null;

                try
                {
                    flag = result.OnReleaseConnectionPoolScheduled();
                }
                catch (Exception exception2)
                {
                    if (Fx.IsFatal(exception2))
                    {
                        throw;
                    }
                    flag      = true;
                    exception = exception2;
                }
                if (flag)
                {
                    result.Complete(false, exception);
                }
            }
 private static void OnCloseComplete(IAsyncResult result)
 {
     if (!result.CompletedSynchronously)
     {
         ConnectionOrientedTransportChannelFactory <TChannel> .CloseAsyncResult asyncState = (ConnectionOrientedTransportChannelFactory <TChannel> .CloseAsyncResult)result.AsyncState;
         Exception exception = null;
         try
         {
             asyncState.upgradeProvider.EndClose(result);
         }
         catch (Exception exception2)
         {
             if (Fx.IsFatal(exception2))
             {
                 throw;
             }
             exception = exception2;
         }
         asyncState.Complete(false, exception);
     }
 }