static void OnOperationComplete(IAsyncResult result, bool isSender, bool isOpen)
        {
            OperationState          state   = (OperationState)result.AsyncState;
            RequestResponseAmqpLink thisPtr = state.Owner;
            AmqpLink link = isSender ? (AmqpLink)thisPtr.sender : thisPtr.receiver;

            Exception completeException = null;

            try
            {
                if (isOpen)
                {
                    link.EndOpen(result);
                }
                else
                {
                    link.EndClose(result);
                }
            }
            catch (Exception exception)
            {
                if (Fx.IsFatal(exception))
                {
                    throw;
                }

                completeException = exception;
            }

            if (state.Complete() || completeException != null)
            {
                if (isOpen)
                {
                    thisPtr.CompleteOpen(false, completeException);
                }
                else
                {
                    thisPtr.CompleteClose(false, completeException);
                }
            }
        }