private void ProcessCloseOrTerminateReply(bool close, Message reply)
        {
            if (reply == null)
            {
                throw Fx.AssertAndThrow("Argument reply cannot be null.");
            }
            ReliableRequestor requestor = close ? this.closeRequestor : this.terminateRequestor;

            if (requestor.GetInfo() == null)
            {
                try
                {
                    WsrmMessageInfo info = WsrmMessageInfo.Get(this.Settings.MessageVersion, this.Settings.ReliableMessagingVersion, this.binder.Channel, this.binder.GetInnerSession(), reply);
                    this.ReliableSession.ProcessInfo(info, null, true);
                    this.ReliableSession.VerifyDuplexProtocolElements(info, null, true);
                    WsrmFault fault = close ? WsrmUtilities.ValidateCloseSequenceResponse(this.session, requestor.MessageId, info, this.connection.Last) : WsrmUtilities.ValidateTerminateSequenceResponse(this.session, requestor.MessageId, info, this.connection.Last);
                    if (fault != null)
                    {
                        this.ReliableSession.OnLocalFault(null, fault, null);
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(fault.CreateException());
                    }
                }
                finally
                {
                    reply.Close();
                }
            }
        }
        private void ProcessCloseOrTerminateReply(bool close, Message reply)
        {
            if (reply == null)
            {
                // In the close case, the requestor is configured to throw TimeoutException instead of returning null.
                // In the terminate case, this value can be null, but the caller should not call this method.
                throw Fx.AssertAndThrow("Argument reply cannot be null.");
            }

            ReliableRequestor requestor = close ? _closeRequestor : _terminateRequestor;
            WsrmMessageInfo   info      = requestor.GetInfo();

            // Some other thread has verified and cleaned up the reply, no more work to do.
            if (info != null)
            {
                return;
            }

            try
            {
                info = WsrmMessageInfo.Get(Settings.MessageVersion, Settings.ReliableMessagingVersion,
                                           _binder.Channel, _binder.GetInnerSession(), reply);
                ReliableSession.ProcessInfo(info, null, true);
                ReliableSession.VerifyDuplexProtocolElements(info, null, true);

                WsrmFault fault = close
                    ? WsrmUtilities.ValidateCloseSequenceResponse(_session, requestor.MessageId, info,
                                                                  Connection.Last)
                    : WsrmUtilities.ValidateTerminateSequenceResponse(_session, requestor.MessageId, info,
                                                                      Connection.Last);

                if (fault != null)
                {
                    ReliableSession.OnLocalFault(null, fault, null);
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(fault.CreateException());
                }
            }
            finally
            {
                reply.Close();
            }
        }