Skip to content

PeekableStream.PeekAsync Method

Definition

Asynchronously reads the next byte from the stream without consuming it. Subsequent calls to PeekAsync(CancellationToken) will return the same value until the byte is consumed by a read operation, or the position is changed.

public ValueTask<int> PeekAsync(CancellationToken cancellationToken = null);

Parameters

Name Type Description
cancellationToken CancellationToken An optional token to cancel the operation.

Returns

ValueTask<Int32>

A task yielding the next byte in the stream, or -1 if the end of the stream has been reached.