internal static Message End(IAsyncResult result, out SecurityProtocolCorrelationState newCorrelationState)
            {
                GetTwoTokensAndSetUpSecurityAsyncResult self = AsyncResult.End <GetTwoTokensAndSetUpSecurityAsyncResult>(result);

                newCorrelationState = self.newCorrelationState;
                return(self.message);
            }
            static void GetSecondaryTokenCompleteCallback(IAsyncResult result)
            {
                if (result == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("result");
                }
                if (result.CompletedSynchronously)
                {
                    return;
                }
                GetTwoTokensAndSetUpSecurityAsyncResult self = result.AsyncState as GetTwoTokensAndSetUpSecurityAsyncResult;

                if (self == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("result", SR.GetString(SR.InvalidAsyncResult));
                }
                bool      completeSelf        = false;
                Exception completionException = null;

                try
                {
                    SecurityToken token = self.secondaryProvider.EndGetToken(result);
                    completeSelf = self.OnGetSecondaryTokenComplete(token);
                }
#pragma warning suppress 56500 // covered by FxCOP
                catch (Exception e)
                {
                    // Always immediately rethrow fatal exceptions.
                    if (Fx.IsFatal(e))
                    {
                        throw;
                    }

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