in src/AmqpObject.cs [161:213]
internal void CloseInternal(int waitMilliseconds, Error error = null)
{
lock (this)
{
if (this.closedCalled)
{
return;
}
this.closedCalled = true;
}
// initialize event first to avoid the race with NotifyClosed
if (waitMilliseconds > 0)
{
this.endEvent = new ManualResetEvent(false);
}
this.Error = error;
if (!this.OnClose(error))
{
if (waitMilliseconds > 0)
{
try
{
if (!this.endEvent.WaitOne(waitMilliseconds))
{
throw new TimeoutException(Fx.Format(SRAmqp.AmqpTimeout,
"close", waitMilliseconds, this.GetType().Name));
}
if (this.error != null && this.error != error)
{
throw new AmqpException(this.error);
}
}
finally
{
this.NotifyClosed(this.Error);
}
}
}
else
{
if (waitMilliseconds > 0)
{
this.endEvent.Set();
}
this.NotifyClosed(this.Error);
}
}