public static async Task SendAsync(this ITransportChannel channel, Stream content, long length) { if (!await channel.TrySendAsync(content, length).ConfigureAwait(false)) { throw new OperationCanceledException(); } }
public static async Task SendMessageAsync( this ITransportChannel channel, byte[] buffer, int offset, int count) { using (var stream = new MemoryStream(buffer, offset, count)) { await channel.TrySendAsync(stream, count).ConfigureAwait(false); } }