private static void OnReadUpgradeResponse(object state)
            {
                Microsoft.ServiceBus.Channels.ConnectionUpgradeHelper.InitiateUpgradeAsyncResult initiateUpgradeAsyncResult = (Microsoft.ServiceBus.Channels.ConnectionUpgradeHelper.InitiateUpgradeAsyncResult)state;
                Exception exception = null;
                bool      flag      = false;

                try
                {
                    if (initiateUpgradeAsyncResult.CompleteReadUpgradeResponse())
                    {
                        flag = initiateUpgradeAsyncResult.Begin();
                    }
                }
                catch (Exception exception2)
                {
                    Exception exception1 = exception2;
                    if (Fx.IsFatal(exception1))
                    {
                        throw;
                    }
                    flag      = true;
                    exception = exception1;
                }
                if (flag)
                {
                    initiateUpgradeAsyncResult.Complete(false, exception);
                }
            }
            private static void OnWriteUpgradeBytes(IAsyncResult result)
            {
                if (result.CompletedSynchronously)
                {
                    return;
                }
                Microsoft.ServiceBus.Channels.ConnectionUpgradeHelper.InitiateUpgradeAsyncResult asyncState = (Microsoft.ServiceBus.Channels.ConnectionUpgradeHelper.InitiateUpgradeAsyncResult)result.AsyncState;
                Exception exception = null;
                bool      flag      = false;

                try
                {
                    if (asyncState.CompleteWriteUpgradeBytes(result))
                    {
                        flag = asyncState.Begin();
                    }
                }
                catch (Exception exception2)
                {
                    Exception exception1 = exception2;
                    if (Fx.IsFatal(exception1))
                    {
                        throw;
                    }
                    flag      = true;
                    exception = exception1;
                }
                if (flag)
                {
                    asyncState.Complete(false, exception);
                }
            }
            private static void OnFailedUpgrade(IAsyncResult result)
            {
                if (result.CompletedSynchronously)
                {
                    return;
                }
                Microsoft.ServiceBus.Channels.ConnectionUpgradeHelper.InitiateUpgradeAsyncResult asyncState = (Microsoft.ServiceBus.Channels.ConnectionUpgradeHelper.InitiateUpgradeAsyncResult)result.AsyncState;
                Exception exception = null;

                try
                {
                    Microsoft.ServiceBus.Channels.ConnectionUpgradeHelper.EndDecodeFramingFault(result);
                }
                catch (Exception exception2)
                {
                    Exception exception1 = exception2;
                    if (Fx.IsFatal(exception1))
                    {
                        throw;
                    }
                    exception = exception1;
                }
                asyncState.Complete(false, exception);
            }