IsolatedStorageFileStream.ReadAsync 方法

定义

重载

名称 说明
ReadAsync(Byte[], Int32, Int32, CancellationToken)

将字节从当前缓冲 IsolatedStorageFileStream 的对象异步复制到字节数组。

ReadAsync(Memory<Byte>, CancellationToken)

将字节从当前缓冲 IsolatedStorageFileStream 的对象异步复制到字节内存范围。

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

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

将字节从当前缓冲 IsolatedStorageFileStream 的对象异步复制到字节数组。

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)

参数

buffer
Byte[]

要将数据写入到的缓冲区。

offset
Int32

要开始写入的缓冲区中的偏移量。

count
Int32

要读取的最大字节数。

cancellationToken
CancellationToken

用于监视取消请求的令牌。 默认值为 None

返回

表示异步读取操作的任务。 它将读取到的字节总数包装到 。buffer 如果多个字节当前不可用,则这可以小于请求的字节数;如果到达流的末尾,则为零。

例外

取消令牌已取消。 此异常存储在返回的任务中。

注解

参数buffer可以是类的Buffer实例,也可以是下列类型之一的数组:Byte、、SByte、、CharInt16Int32Int64UInt16UInt32UInt64或。 SingleDouble

如果读取操作成功,则流当前位置按读取的字节数进行高级。 如果发生异常,则流的当前位置保持不变。

该方法 ReadAsyncbuffer 参数视为字节块,而不考虑其实际类型。 同样,始终 offset 以字节为单位指定和 count 参数。 对于buffer字节数组以外的参数,这意味着元素索引或元素数必须乘以字节为单位的元素大小,才能为或offset形成正确的值count

ReadAsync仅当到达流的末尾时,该方法才会返回零。 在所有其他情况下,在返回之前, ReadAsync 始终从流中读取至少一个字节。 如果在调用IsolatedStorageFileStream对象时没有数据可用ReadAsync,该方法将阻止,直到可以返回至少一个字节的数据。

此方法存储在任务中,它返回该方法的同步对应项可以引发的所有非使用异常。 如果异常存储在返回的任务中,则等待任务时将引发该异常。 使用情况异常(例如 ArgumentException)仍会同步引发。 有关存储的异常,请参阅由 Read(Byte[], Int32, Int32)..

适用于

ReadAsync(Memory<Byte>, CancellationToken)

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

将字节从当前缓冲 IsolatedStorageFileStream 的对象异步复制到字节内存范围。

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)

参数

buffer
Memory<Byte>

要将数据写入到的缓冲区。

cancellationToken
CancellationToken

用于监视取消请求的令牌。 默认值为 None

返回

表示异步读取操作的任务。 它将读取到的字节总数包装到 。buffer 如果多个字节当前不可用,则这可以小于请求的字节数;如果到达流的末尾,则为零。

例外

取消令牌已取消。 此异常存储在返回的任务中。

适用于