MemoryStream.EndRead(IAsyncResult) 方法

定義

等候暫止的非同步讀取完成。Waits for the pending asynchronous read to complete. (請考慮用 ReadAsync(Byte[], Int32, Int32, CancellationToken) 替代。)(Consider using ReadAsync(Byte[], Int32, Int32, CancellationToken) instead.)

public:
 override int EndRead(IAsyncResult ^ asyncResult);
public override int EndRead (IAsyncResult asyncResult);
override this.EndRead : IAsyncResult -> int
Public Overrides Function EndRead (asyncResult As IAsyncResult) As Integer

參數

asyncResult
IAsyncResult

要完成的擱置中非同步要求的參考。The reference to the pending asynchronous request to finish.

傳回

從記憶體資料流讀取的位元組數,介於零 (0) 和您所要求的位元組數之間。The number of bytes read from the memory stream, between zero (0) and the number of bytes you requested. 只在記憶體資料流結尾傳回零 (0),否則,應會封鎖到至少有一個位元組可用為止。Returns zero (0) only at the end of the memory stream, otherwise, it should block until at least one byte is available.

例外狀況

asyncResultnullasyncResult is null.

暫止讀取作業的控制代碼無法使用。A handle to the pending read operation is not available.

-或--or-

暫止的作業不支援讀取。The pending operation does not support reading.

asyncResult 不是源自目前記憶體資料流上的 BeginRead(Byte[], Int32, Int32, AsyncCallback, Object) 方法。asyncResult did not originate from a BeginRead(Byte[], Int32, Int32, AsyncCallback, Object) method on the current memory stream.

資料流已關閉或發生內部錯誤。The stream is closed or an internal error has occurred.

備註

如需此方法的其他使用方式資訊,請參閱 EndRead 備註。Refer to the EndRead remarks for additional usage information for this method.

適用於