QuicStream.ReadAsync Method

Definition

Overloads

ReadAsync(Memory<Byte>, CancellationToken)

Asynchronously reads a sequence of bytes from the current stream, advances the position within the stream by the number of bytes read, and monitors cancellation requests.

ReadAsync(Byte[], Int32, Int32, CancellationToken)

Asynchronously reads a sequence of bytes from the current stream, advances the position within the stream by the number of bytes read, and monitors cancellation requests.

ReadAsync(Memory<Byte>, CancellationToken)

Source:
QuicStream.cs
Source:
QuicStream.cs
Source:
QuicStream.cs

Asynchronously reads a sequence of bytes from the current stream, advances the position within the stream by the number of bytes read, and monitors cancellation requests.

public override System.Threading.Tasks.ValueTask<int> ReadAsync (Memory<byte> buffer, System.Threading.CancellationToken cancellationToken = default);

Parameters

buffer
Memory<Byte>

The region of memory to write the data into.

cancellationToken
CancellationToken

The token to monitor for cancellation requests. The default value is None.

Returns

A task that represents the asynchronous read operation.

Exceptions

The cancellation token was canceled. This exception is stored into the returned task.

Remarks

The value of its Result property contains the total number of bytes read into the buffer. The result value can be less than the length of the buffer if that many bytes are not currently available, or it can be 0 (zero) if the length of the buffer is 0 or if the end of the stream has been reached.

Applies to

.NET 9 וגירסאות אחרות
מוצר גירסאות
.NET 7, 8, 9

ReadAsync(Byte[], Int32, Int32, CancellationToken)

Source:
QuicStream.Stream.cs
Source:
QuicStream.Stream.cs
Source:
QuicStream.Stream.cs

Asynchronously reads a sequence of bytes from the current stream, advances the position within the stream by the number of bytes read, and monitors cancellation requests.

public override System.Threading.Tasks.Task<int> ReadAsync (byte[] buffer, int offset, int count, System.Threading.CancellationToken cancellationToken = default);

Parameters

buffer
Byte[]

The buffer to write the data into.

offset
Int32

The byte offset in buffer at which to begin writing data from the stream.

count
Int32

The maximum number of bytes to read.

cancellationToken
CancellationToken

The token to monitor for cancellation requests. The default value is None.

Returns

A task that represents the asynchronous read operation.

Exceptions

The cancellation token was canceled. This exception is stored into the returned task.

Remarks

The value of the Result property contains the total number of bytes read into the buffer. The result value can be less than the number of bytes requested if the number of bytes currently available is less than the requested number, or it can be 0 (zero) if count is 0 or if the end of the stream has been reached.

Applies to

.NET 9 וגירסאות אחרות
מוצר גירסאות
.NET 7, 8, 9