CanTransite() public static method

public static CanTransite ( AmqpObjectState from, StateTransition states ) : bool
from AmqpObjectState
states StateTransition
return bool
Example #1
0
        public void SafeClose(Exception exception)
        {
            this.TerminalException = exception;

            lock (this.thisLock)
            {
                if (this.State != AmqpObjectState.OpenReceived &&
                    !this.IsClosing() &&
                    !StateTransition.CanTransite(this.State, StateTransition.SendClose))
                {
                    this.State = AmqpObjectState.Faulted;
                }
            }

            try
            {
                this.BeginClose(TimeSpan.FromSeconds(AmqpConstants.DefaultTryCloseTimeout), onSafeCloseComplete, this);
            }
            catch (Exception exp)
            {
                if (Fx.IsFatal(exp))
                {
                    throw;
                }

                AmqpTrace.Provider.AmqpLogError(this, "SafeClose", exp.ToString());

                this.Abort();
            }
        }
Example #2
0
        /// <summary>
        /// Closes the object with exception handling in the background.
        /// </summary>
        /// <param name="exception">The error for closing the object.</param>
        public void SafeClose(Exception exception)
        {
            this.TerminalException = exception;

            lock (this.thisLock)
            {
                if (this.State != AmqpObjectState.OpenReceived &&
                    !this.IsClosing() &&
                    !StateTransition.CanTransite(this.State, StateTransition.SendClose))
                {
                    this.State = AmqpObjectState.Faulted;
                }
            }

            try
            {
                this.BeginClose(AmqpConstants.DefaultTimeout, onSafeCloseComplete, this);
            }
            catch (Exception exp) when(!Fx.IsFatal(exp))
            {
                AmqpTrace.Provider.AmqpLogError(this, nameof(SafeClose), exp);

                this.Abort();
            }
        }