예제 #1
0
        private static void SharedCallback(IAsyncResult result)
        {
            if (result == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError((Exception) new ArgumentNullException("result"));
            }
            if (result.CompletedSynchronously)
            {
                return;
            }
            ApplySecurityAndSendAsyncResult <MessageSenderType> asyncState = result.AsyncState as ApplySecurityAndSendAsyncResult <MessageSenderType>;

            if (asyncState == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError((Exception) new ArgumentException(SR.GetString("InvalidAsyncResult"), "result"));
            }
            Exception exception = (Exception)null;
            bool      flag;

            try
            {
                if (!asyncState.secureOutgoingMessageDone)
                {
                    Message message;
                    asyncState.binding.EndSecureOutgoingMessage(result, out message, out asyncState.newCorrelationState);
                    flag = asyncState.OnSecureOutgoingMessageComplete(message);
                }
                else
                {
                    asyncState.EndSendCore(asyncState.channel, result);
                    flag = asyncState.OnSendComplete();
                }
            }
            catch (Exception ex)
            {
                if (Fx.IsFatal(ex))
                {
                    throw;
                }
                else
                {
                    flag      = true;
                    exception = ex;
                }
            }
            if (!flag)
            {
                return;
            }
            asyncState.Complete(false, exception);
        }
        static void SharedCallback(IAsyncResult result)
        {
            if (result == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("result"));
            }
            if (result.CompletedSynchronously)
            {
                return;
            }
            ApplySecurityAndSendAsyncResult <MessageSenderType> self = result.AsyncState as ApplySecurityAndSendAsyncResult <MessageSenderType>;

            if (self == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.GetString(SR.InvalidAsyncResult), "result"));
            }

            bool      completeSelf        = false;
            Exception completionException = null;

            try
            {
                if (!self.secureOutgoingMessageDone)
                {
                    Message message;
                    self.binding.EndSecureOutgoingMessage(result, out message, out self.newCorrelationState);
                    completeSelf = self.OnSecureOutgoingMessageComplete(message);
                }
                else
                {
                    self.EndSendCore(self.channel, result);
                    completeSelf = self.OnSendComplete();
                }
            }
#pragma warning suppress 56500 // covered by FxCOP
            catch (Exception e)
            {
                if (Fx.IsFatal(e))
                {
                    throw;
                }

                completeSelf        = true;
                completionException = e;
            }
            if (completeSelf)
            {
                self.Complete(false, completionException);
            }
        }