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();
}
}