Edit

Share via


StreamExtensions.ReadAsync Method

Definition

Caution

This API is only available for binary compatibility, but Stream.ReadAsync should be used instead.

Asynchronously reads a sequence of bytes from a given Stream instance.

[System.Obsolete("This API is only available for binary compatibility, but Stream.ReadAsync should be used instead.")]
public static System.Threading.Tasks.ValueTask<int> ReadAsync(this System.IO.Stream stream, Memory<byte> buffer, System.Threading.CancellationToken cancellationToken = default);
public static System.Threading.Tasks.ValueTask<int> ReadAsync(this System.IO.Stream stream, Memory<byte> buffer, System.Threading.CancellationToken cancellationToken = default);
[<System.Obsolete("This API is only available for binary compatibility, but Stream.ReadAsync should be used instead.")>]
static member ReadAsync : System.IO.Stream * Memory<byte> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<int>
static member ReadAsync : System.IO.Stream * Memory<byte> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<int>
<Extension()>
Public Function ReadAsync (stream As Stream, buffer As Memory(Of Byte), Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of Integer)

Parameters

stream
Stream

The source Stream to read data from.

buffer
Memory<Byte>

The destination Memory<T> to write data to.

cancellationToken
CancellationToken

The optional CancellationToken for the operation.

Returns

A ValueTask representing the operation being performed.

Attributes

Applies to