public static Task<Message> ReceiveAsync(this ReceiverLink receiver, int timeout = 60000)
{
TaskCompletionSource<Message> tcs = new TaskCompletionSource<Message>();
try
{
var message = receiver.ReceiveInternal(
(l, m) => tcs.SetResult(m),
timeout);
if (message != null)
{
tcs.SetResult(message);
}
}
catch (Exception exception)
{
tcs.SetException(exception);
}
return tcs.Task;
}