public static async Task <BytesReadPair> ReadAsync(this Stream stream, int length) { BytesReadPair pair = new BytesReadPair() { Buffer = new byte[length], }; var real = await stream.ReadAsync(pair.Buffer, 0, length).ConfigureAwait(false); pair.Length = real; return(pair); }
public static BytesReadPair Read(this Stream stream, int length) { BytesReadPair pair = new BytesReadPair() { Buffer = new byte[length], }; var real = stream.Read(pair.Buffer, 0, length); pair.Length = real; return(pair); }