public static Task CloseAsync(this AmqpObject amqpObject, int timeout = 60000) { TaskCompletionSource<object> tcs = new TaskCompletionSource<object>(); try { amqpObject.Closed += (o, e) => { if (e != null) { tcs.SetException(new AmqpException(e)); } else { tcs.SetResult(null); } }; amqpObject.Close(0); } catch (Exception exception) { tcs.SetException(exception); } return tcs.Task; }