Пример #1
0
        //
        internal bool EndTryReceive(IAsyncResult result, out MsmqInputMessage msmqMessage, out MsmqMessageProperty msmqProperty)
        {
            msmqMessage  = null;
            msmqProperty = null;

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

            if (this.receiveParameters.ExactlyOnce)
            {
                TryTransactedReceiveAsyncResult receiveResult = result as TryTransactedReceiveAsyncResult;
                if (null == receiveResult)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(SR.GetString(SR.InvalidAsyncResult));
                }
                return(TryTransactedReceiveAsyncResult.End(receiveResult, out msmqMessage, out msmqProperty));
            }
            else
            {
                TryNonTransactedReceiveAsyncResult receiveResult = result as TryNonTransactedReceiveAsyncResult;
                if (null == receiveResult)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(SR.GetString(SR.InvalidAsyncResult));
                }
                return(TryNonTransactedReceiveAsyncResult.End(receiveResult, out msmqMessage, out msmqProperty));
            }
        }
        internal bool EndTryReceive(IAsyncResult result, out MsmqInputMessage msmqMessage, out MsmqMessageProperty msmqProperty)
        {
            msmqMessage  = null;
            msmqProperty = null;
            if (result == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("result");
            }
            if (this.receiveParameters.ExactlyOnce)
            {
                TryTransactedReceiveAsyncResult result2 = result as TryTransactedReceiveAsyncResult;
                if (result2 == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(System.ServiceModel.SR.GetString("InvalidAsyncResult"));
                }
                return(TryTransactedReceiveAsyncResult.End(result2, out msmqMessage, out msmqProperty));
            }
            TryNonTransactedReceiveAsyncResult result3 = result as TryNonTransactedReceiveAsyncResult;

            if (result3 == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(System.ServiceModel.SR.GetString("InvalidAsyncResult"));
            }
            return(TryNonTransactedReceiveAsyncResult.End(result3, out msmqMessage, out msmqProperty));
        }