public bool EndWaitForMessage(IAsyncResult result)
 {
     bool flag;
     if (result == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("result");
     }
     DoneReceivingAsyncResult result2 = result as DoneReceivingAsyncResult;
     if (result2 != null)
     {
         return DoneReceivingAsyncResult.End(result2);
     }
     try
     {
         flag = this.receiver.EndWaitForMessage(result);
     }
     catch (MsmqException exception)
     {
         if (exception.FaultReceiver)
         {
             this.listener.FaultListener();
             base.Fault();
         }
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(exception.Normalized);
     }
     return flag;
 }
        public bool EndWaitForMessage(IAsyncResult result)
        {
            if (null == result)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("result");
            }

            DoneReceivingAsyncResult doneRecevingResult = result as DoneReceivingAsyncResult;

            if (doneRecevingResult != null)
            {
                return(DoneReceivingAsyncResult.End(doneRecevingResult));
            }

            try
            {
                return(this.receiver.EndWaitForMessage(result));
            }
            catch (MsmqException ex)
            {
                if (ex.FaultReceiver)
                {
                    this.listener.FaultListener();
                    this.Fault();
                }
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(ex.Normalized);
            }
        }
        public bool EndWaitForMessage(IAsyncResult result)
        {
            bool flag3;

            base.ThrowIfNotOpened();
            if (result == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("result");
            }
            DoneReceivingAsyncResult result2 = result as DoneReceivingAsyncResult;

            if (result2 != null)
            {
                return(DoneReceivingAsyncResult.End(result2));
            }
            bool flag = true;

            try
            {
                bool flag2 = this.messageSource.EndWaitForMessage(result);
                flag  = !flag2;
                flag3 = flag2;
            }
            finally
            {
                if (flag)
                {
                    base.Fault();
                }
            }
            return(flag3);
        }
Exemple #4
0
        public bool EndWaitForMessage(IAsyncResult result)
        {
            this.ThrowIfNotOpened(); // we can't be in Created or Opening
            if (result == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("result");
            }

            DoneReceivingAsyncResult doneRecevingResult = result as DoneReceivingAsyncResult;

            if (doneRecevingResult != null)
            {
                return(DoneReceivingAsyncResult.End(doneRecevingResult));
            }

            bool shouldFault = true;

            try
            {
                bool success = this.messageSource.EndWaitForMessage(result);
                shouldFault = !success; // need to fault if we've timed out because we're now toast
                return(success);
            }
            finally
            {
                if (shouldFault)
                {
                    this.Fault();
                }
            }
        }
 public bool EndTryReceive(IAsyncResult result, out Message message)
 {
     bool flag2;
     message = null;
     if (result == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("result");
     }
     DoneReceivingAsyncResult result2 = result as DoneReceivingAsyncResult;
     if (result2 != null)
     {
         return DoneReceivingAsyncResult.End(result2);
     }
     MsmqInputMessage msmqMessage = null;
     MsmqMessageProperty msmqProperty = null;
     try
     {
         bool flag = this.receiver.EndTryReceive(result, out msmqMessage, out msmqProperty);
         if (flag)
         {
             if (msmqProperty != null)
             {
                 message = this.DecodeMsmqMessage(msmqMessage, msmqProperty);
                 message.Properties["MsmqMessageProperty"] = msmqProperty;
                 if (this.receiveParameters.ReceiveContextSettings.Enabled)
                 {
                     message.Properties[ReceiveContext.Name] = this.receiveContextManager.CreateMsmqReceiveContext(msmqMessage.LookupId.Value);
                 }
                 MsmqDiagnostics.DatagramReceived(msmqMessage.MessageId, message);
                 this.listener.RaiseMessageReceived();
             }
             else if (CommunicationState.Opened == base.State)
             {
                 this.listener.FaultListener();
                 base.Fault();
             }
         }
         flag2 = flag;
     }
     catch (MsmqException exception)
     {
         if (exception.FaultReceiver)
         {
             this.listener.FaultListener();
             base.Fault();
         }
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(exception.Normalized);
     }
     finally
     {
         if (msmqMessage != null)
         {
             this.receiver.ReturnMessage(msmqMessage);
         }
     }
     return flag2;
 }
        //
        public override IInputSessionChannel EndAcceptChannel(IAsyncResult result)
        {
            if (null == result)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("result");
            }

            DoneReceivingAsyncResult doneRecevingResult = result as DoneReceivingAsyncResult;

            if (doneRecevingResult != null)
            {
                DoneReceivingAsyncResult.End(doneRecevingResult);
                return(null);
            }

            MsmqInputMessage    msmqMessage = null;
            MsmqMessageProperty property    = null;

            try
            {
                bool retval = this.receiver.EndTryReceive(result, out msmqMessage, out property);
                if (retval)
                {
                    if (null != property)
                    {
                        return(MsmqDecodeHelper.DecodeTransportSessiongram(this, msmqMessage, property, this.receiveContextManager));
                    }
                    else
                    {
                        if (CommunicationState.Opened == this.State)
                        {
                            this.Fault();
                        }
                        return(null);
                    }
                }
                else
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new TimeoutException());
                }
            }
            catch (MsmqException ex)
            {
                if (ex.FaultReceiver)
                {
                    this.Fault();
                }
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(ex.Normalized);
            }
            finally
            {
                if (null != msmqMessage)
                {
                    this.receiver.ReturnMessage(msmqMessage);
                }
            }
        }
Exemple #7
0
            public virtual bool EndTryReceive(IAsyncResult result, out Message message)
            {
                DoneReceivingAsyncResult result2 = result as DoneReceivingAsyncResult;

                if (result2 != null)
                {
                    return(DoneReceivingAsyncResult.End(result2, out message));
                }
                return(ReceiveMessageAndVerifySecurityAsyncResultBase.End(result, out message));
            }
Exemple #8
0
            public virtual bool EndTryReceive(IAsyncResult result, out Message message)
            {
                DoneReceivingAsyncResult doneRecevingResult = result as DoneReceivingAsyncResult;

                if (doneRecevingResult != null)
                {
                    return(DoneReceivingAsyncResult.End(doneRecevingResult, out message));
                }

                return(ClientDuplexReceiveMessageAndVerifySecurityAsyncResult.End(result, out message));
            }
Exemple #9
0
        public override IInputSessionChannel EndAcceptChannel(IAsyncResult result)
        {
            IInputSessionChannel channel;

            if (result == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("result");
            }
            DoneReceivingAsyncResult result2 = result as DoneReceivingAsyncResult;

            if (result2 != null)
            {
                DoneReceivingAsyncResult.End(result2);
                return(null);
            }
            MsmqInputMessage    msmqMessage  = null;
            MsmqMessageProperty msmqProperty = null;

            try
            {
                if (!this.receiver.EndTryReceive(result, out msmqMessage, out msmqProperty))
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new TimeoutException());
                }
                if (msmqProperty != null)
                {
                    return(MsmqDecodeHelper.DecodeTransportSessiongram(this, msmqMessage, msmqProperty, this.receiveContextManager));
                }
                if (CommunicationState.Opened == base.State)
                {
                    base.Fault();
                }
                channel = null;
            }
            catch (MsmqException exception)
            {
                if (exception.FaultReceiver)
                {
                    base.Fault();
                }
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(exception.Normalized);
            }
            finally
            {
                if (msmqMessage != null)
                {
                    this.receiver.ReturnMessage(msmqMessage);
                }
            }
            return(channel);
        }
Exemple #10
0
        public Message EndReceive(IAsyncResult result)
        {
            this.ThrowIfNotOpened(); // we can't be in Created or Opening
            if (result == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("result");
            }

            DoneReceivingAsyncResult doneReceivingResult = result as DoneReceivingAsyncResult;

            if (doneReceivingResult != null)
            {
                DoneReceivingAsyncResult.End(doneReceivingResult);
                return(null);
            }

            bool    shouldFault = true;
            Message message     = null;

            try
            {
                message = this.messageSource.EndReceive(result);
                this.OnReceiveMessage(message);
                shouldFault = false;
                return(message);
            }
            finally
            {
                if (shouldFault)
                {
                    if (message != null)
                    {
                        message.Close();
                        message = null;
                    }

                    this.Fault();
                }
            }
        }
        public Message EndReceive(IAsyncResult result)
        {
            Message message2;

            base.ThrowIfNotOpened();
            if (result == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("result");
            }
            DoneReceivingAsyncResult result2 = result as DoneReceivingAsyncResult;

            if (result2 != null)
            {
                DoneReceivingAsyncResult.End(result2);
                return(null);
            }
            bool    flag    = true;
            Message message = null;

            try
            {
                message = this.messageSource.EndReceive(result);
                this.OnReceiveMessage(message);
                flag     = false;
                message2 = message;
            }
            finally
            {
                if (flag)
                {
                    if (message != null)
                    {
                        message.Close();
                        message = null;
                    }
                    base.Fault();
                }
            }
            return(message2);
        }
        public bool EndTryReceive(IAsyncResult result, out Message message)
        {
            message = null;

            if (null == result)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("result");
            }

            DoneReceivingAsyncResult doneRecevingResult = result as DoneReceivingAsyncResult;

            if (doneRecevingResult != null)
            {
                return(DoneReceivingAsyncResult.End(doneRecevingResult));
            }

            MsmqInputMessage    msmqMessage = null;
            MsmqMessageProperty property    = null;

            try
            {
                bool retval = this.receiver.EndTryReceive(result, out msmqMessage, out property);
                if (retval)
                {
                    if (null != property)
                    {
                        message = DecodeMsmqMessage(msmqMessage, property);
                        message.Properties[MsmqMessageProperty.Name] = property;

                        if (this.receiveParameters.ReceiveContextSettings.Enabled)
                        {
                            message.Properties[MsmqReceiveContext.Name] = this.receiveContextManager.CreateMsmqReceiveContext(msmqMessage.LookupId.Value);
                        }

                        MsmqDiagnostics.DatagramReceived(msmqMessage.MessageId, message);
                        this.listener.RaiseMessageReceived();
                    }
                    else if (CommunicationState.Opened == this.State)
                    {
                        this.listener.FaultListener();
                        this.Fault();
                    }
                }
                return(retval);
            }
            catch (MsmqException ex)
            {
                if (ex.FaultReceiver)
                {
                    this.listener.FaultListener();
                    this.Fault();
                }
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(ex.Normalized);
            }
            finally
            {
                if (null != msmqMessage)
                {
                    this.receiver.ReturnMessage(msmqMessage);
                }
            }
        }