// 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)); } }
static void OnComplete(object parameter) { TryTransactedReceiveAsyncResult result = parameter as TryTransactedReceiveAsyncResult; Transaction savedTransaction = Transaction.Current; Transaction.Current = result.txCurrent; try { Exception ex = null; try { result.expired = !result.receiver.TryReceive(result.msmqMessage, result.timeoutHelper.RemainingTime(), result.transactionMode, out result.messageProperty); } catch (Exception e) { if (Fx.IsFatal(e)) { throw; } ex = e; } result.Complete(false, ex); } finally { Transaction.Current = savedTransaction; } }
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)); }
internal static bool End(IAsyncResult result, out MsmqInputMessage msmqMessage, out MsmqMessageProperty property) { TryTransactedReceiveAsyncResult receiveResult = AsyncResult.End <TryTransactedReceiveAsyncResult>(result); msmqMessage = receiveResult.msmqMessage; property = receiveResult.messageProperty; return(!receiveResult.expired); }