/// <summary> /// Asyncronously reads <paramref name="count"/> bytes. /// </summary> /// <param name="count">The number of bytes to read.</param> /// <returns>A <see cref="Task"/> that completes when the entire read operation has completed. The result of the task contains the array of bytes that was read.</returns> /// <exception cref="EndOfStreamException">Thrown when the end of the stream is reached before the read is completed.</exception> public static async Task <byte[]> ReadBytesAsync(this IReadBytes reader, int count) { var bytes = new byte[count]; await reader.ReadBytesAsync(bytes, 0, count).ConfigureAwait(false); return(bytes); }