public static Task SendBatchAsync(this QueueClient queueClient, IEnumerable <BrokeredMessage> messages) { var tcs = new TaskCompletionSource <object>(); queueClient.BeginSendBatch(messages, ar => { try { queueClient.EndSendBatch(ar); tcs.SetResult(null); } catch (Exception exception) { tcs.SetException(exception); } }, null); return(tcs.Task); }