Declaration
public static Task<int> FillBufferAsync(
this Stream stream,
byte[] buffer,
int offset,
int length,
CancellationToken? token = null
)
Summary
Attempts to fill the buffer with the specified number of bytes from the stream. If there are fewer bytes left
in the stream than requested then all available bytes will be read into the buffer.
Parameters
this Stream | stream |
Stream to read from. |
byte[] | buffer |
Buffer to write the bytes to. |
int | offset |
Offset at which to write the first byte read from the stream. |
int | length |
Number of bytes to read from the stream. |
CancellationToken? | token |
A cancellation token for this async task. |
Returns
Number of bytes read from the stream into buffer. This may be less than requested, but only if the stream
ended before the required number of bytes were read.