public static CloseAsync ( this amqpObject, int timeout = 60000 ) : System.Threading.Tasks.Task | ||
amqpObject | this | The object to close. |
timeout | int | The timeout in seconds. |
Результат | System.Threading.Tasks.Task |
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;
}