Legend

Class
Struct
Enum
Interface
Delegate
Constructor
Method
Property
Event
Field

Extension method: Task<int> FillBufferAsync(this Stream, byte[], int, int, CancellationToken?)

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 Streamstream Stream to read from.
byte[]buffer Buffer to write the bytes to.
intoffset Offset at which to write the first byte read from the stream.
intlength 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.