public SendAsyncResult(ServiceBusOutputChannel outputChannel, Message message, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state)
            {
                bool flag;
                bool flag1;

                this.outputChannel = outputChannel;
                outputChannel.AddHeadersTo(message);
                outputChannel.TraceSendingMessage(message);
                BrokeredMessage brokerMessage = null;

                try
                {
                    brokerMessage = outputChannel.ConvertToBrokerMessage(message, out this.bufferToReturn);
                    Microsoft.ServiceBus.Messaging.MessageSender messageSender = outputChannel.MessageSender;
                    BrokeredMessage[] brokeredMessageArray = new BrokeredMessage[] { brokerMessage };
                    if (base.SyncContinue(messageSender.BeginSend(brokeredMessageArray, timeout, base.PrepareAsyncCompletion(ServiceBusOutputChannel.SendAsyncResult.onSendComplete), this)))
                    {
                        base.Complete(true);
                    }
                }
                catch (MessagingException messagingException)
                {
                    CommunicationException communicationException = MessagingExceptionHelper.ConvertToCommunicationException(messagingException, out flag);
                    if (flag)
                    {
                        this.outputChannel.Fault();
                    }
                    throw Microsoft.ServiceBus.Messaging.FxTrace.Exception.AsError(communicationException, null);
                }
                catch (OperationCanceledException operationCanceledException1)
                {
                    OperationCanceledException operationCanceledException = operationCanceledException1;
                    MessagingException         innerException             = operationCanceledException.InnerException as MessagingException;
                    if (innerException != null)
                    {
                        MessagingExceptionHelper.ConvertToCommunicationException(innerException, out flag1);
                        if (flag1)
                        {
                            this.outputChannel.Fault();
                        }
                    }
                    ExceptionTrace exception             = Microsoft.ServiceBus.Messaging.FxTrace.Exception;
                    string         entityClosedOrAborted = SRClient.EntityClosedOrAborted;
                    Exception      innerException1       = operationCanceledException.InnerException;
                    if (innerException1 == null)
                    {
                        innerException1 = operationCanceledException;
                    }
                    throw exception.AsError(new CommunicationObjectAbortedException(entityClosedOrAborted, innerException1), null);
                }
                catch (Exception exception1)
                {
                    if (this.bufferToReturn != null)
                    {
                        this.outputChannel.ChannelFactory.BufferManager.ReturnBuffer(this.bufferToReturn);
                    }
                    throw;
                }
            }
 public OpenMessagingFactoryAndMessageSenderAsyncResult(ServiceBusOutputChannel outputChannel, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state)
 {
     this.timeoutHelper = new TimeoutHelper(timeout);
     this.outputChannel = outputChannel;
     try
     {
         if (base.SyncContinue(MessagingFactory.BeginCreate(this.outputChannel.messagingAddress.ResourceAddress, this.outputChannel.messagingFactorySettings, this.timeoutHelper.RemainingTime(), base.PrepareAsyncCompletion(ServiceBusOutputChannel.OpenMessagingFactoryAndMessageSenderAsyncResult.createFactoryComplete), this)))
         {
             base.Complete(true);
         }
     }
     catch (MessagingException messagingException1)
     {
         MessagingException messagingException = messagingException1;
         throw Microsoft.ServiceBus.Messaging.FxTrace.Exception.AsError(MessagingExceptionHelper.ConvertToCommunicationException(messagingException), null);
     }
 }