public CloseAsyncResult(Microsoft.ServiceBus.Channels.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 (Microsoft.ServiceBus.Channels.ConnectionOrientedTransportChannelFactory <TChannel> .CloseAsyncResult.onReleaseConnectionPoolScheduled == null)
         {
             Microsoft.ServiceBus.Channels.ConnectionOrientedTransportChannelFactory <TChannel> .CloseAsyncResult.onReleaseConnectionPoolScheduled = new Action <object>(Microsoft.ServiceBus.Channels.ConnectionOrientedTransportChannelFactory <TChannel> .CloseAsyncResult.OnReleaseConnectionPoolScheduled);
         }
         IOThreadScheduler.ScheduleCallbackNoFlow(Microsoft.ServiceBus.Channels.ConnectionOrientedTransportChannelFactory <TChannel> .CloseAsyncResult.onReleaseConnectionPoolScheduled, this);
     }
     else if (this.HandleReleaseConnectionPoolComplete())
     {
         base.Complete(true);
         return;
     }
 }
            private static void OnOpenComplete(IAsyncResult result)
            {
                if (result.CompletedSynchronously)
                {
                    return;
                }
                Microsoft.ServiceBus.Channels.ConnectionOrientedTransportChannelFactory <TChannel> .OpenAsyncResult asyncState = (Microsoft.ServiceBus.Channels.ConnectionOrientedTransportChannelFactory <TChannel> .OpenAsyncResult)result.AsyncState;
                Exception exception = null;

                try
                {
                    asyncState.communicationObject.EndOpen(result);
                }
                catch (Exception exception2)
                {
                    Exception exception1 = exception2;
                    if (Fx.IsFatal(exception1))
                    {
                        throw;
                    }
                    exception = exception1;
                }
                asyncState.Complete(false, exception);
            }
            private static void OnReleaseConnectionPoolScheduled(object state)
            {
                bool flag;

                Microsoft.ServiceBus.Channels.ConnectionOrientedTransportChannelFactory <TChannel> .CloseAsyncResult closeAsyncResult = (Microsoft.ServiceBus.Channels.ConnectionOrientedTransportChannelFactory <TChannel> .CloseAsyncResult)state;
                Exception exception = null;

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

                try
                {
                    asyncState.upgradeProvider.EndClose(result);
                }
                catch (Exception exception2)
                {
                    Exception exception1 = exception2;
                    if (Fx.IsFatal(exception1))
                    {
                        throw;
                    }
                    exception = exception1;
                }
                asyncState.Complete(false, exception);
            }