Επεξεργασία

Κοινή χρήση μέσω


IsolatedStorageFileStream.ReadAsync Method

Definition

Overloads

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

Asynchronously copies bytes from the current buffered IsolatedStorageFileStream object to a byte array.

ReadAsync(Memory<Byte>, CancellationToken)

Asynchronously copies bytes from the current buffered IsolatedStorageFileStream object to a byte memory range.

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

Source:
IsolatedStorageFileStream.cs
Source:
IsolatedStorageFileStream.cs
Source:
IsolatedStorageFileStream.cs

Asynchronously copies bytes from the current buffered IsolatedStorageFileStream object to a byte array.

public:
 override System::Threading::Tasks::Task<int> ^ ReadAsync(cli::array <System::Byte> ^ buffer, int offset, int count, System::Threading::CancellationToken cancellationToken);
public override System.Threading.Tasks.Task<int> ReadAsync (byte[] buffer, int offset, int count, System.Threading.CancellationToken cancellationToken);
override this.ReadAsync : byte[] * int * int * System.Threading.CancellationToken -> System.Threading.Tasks.Task<int>
Public Overrides Function ReadAsync (buffer As Byte(), offset As Integer, count As Integer, cancellationToken As CancellationToken) As Task(Of Integer)

Parameters

buffer
Byte[]

The buffer to write the data into.

offset
Int32

The offset in the buffer at which to begin writing.

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. It wraps the total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero if the end of the stream is reached.

Exceptions

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

Remarks

The buffer parameter can be an instance of the Buffer class, or an array of one of the following types: Byte, SByte, Char, Int16, Int32, Int64, UInt16, UInt32, UInt64, Single, or Double.

If the read operation is successful, the current position of the stream is advanced by the number of bytes read. If an exception occurs, the current position of the stream is unchanged.

The ReadAsync method treats the buffer parameter as a block of bytes, regardless of its actual type. Likewise, the offset and count parameters are always specified in bytes. For buffer parameters other than byte arrays, this means that an element index or the number of elements must be multiplied by the element size in bytes to form a correct value for offset or count.

The ReadAsync method will return zero only if the end of the stream is reached. In all other cases, ReadAsync always reads at least one byte from the stream before returning. If no data is available from the IsolatedStorageFileStream object upon a call to ReadAsync, the method will block until at least one byte of data can be returned.

This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by Read(Byte[], Int32, Int32).

Applies to

ReadAsync(Memory<Byte>, CancellationToken)

Source:
IsolatedStorageFileStream.cs
Source:
IsolatedStorageFileStream.cs
Source:
IsolatedStorageFileStream.cs

Asynchronously copies bytes from the current buffered IsolatedStorageFileStream object to a byte memory range.

public override System.Threading.Tasks.ValueTask<int> ReadAsync (Memory<byte> buffer, System.Threading.CancellationToken cancellationToken = default);
override this.ReadAsync : Memory<byte> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<int>
Public Overrides Function ReadAsync (buffer As Memory(Of Byte), Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of Integer)

Parameters

buffer
Memory<Byte>

The buffer 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. It wraps the total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero if the end of the stream is reached.

Exceptions

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

Applies to