Stream.EndRead(IAsyncResult) Stream.EndRead(IAsyncResult) Stream.EndRead(IAsyncResult) Stream.EndRead(IAsyncResult) Method


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

 virtual int EndRead(IAsyncResult ^ asyncResult);
public virtual int EndRead (IAsyncResult asyncResult);
abstract member EndRead : IAsyncResult -> int
override this.EndRead : IAsyncResult -> int
Public Overridable Function EndRead (asyncResult As IAsyncResult) As Integer


IAsyncResult IAsyncResult IAsyncResult IAsyncResult

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


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


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


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

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


在 .NET Framework 4 (含) 以前版本中,您必須使用方法 (例如 BeginReadEndRead ) 實作非同步 I/O 作業。In the .NET Framework 4 and earlier versions, you have to use methods such as BeginRead and EndRead to implement asynchronous I/O operations. 這些方法仍.NET Framework 4.5.NET Framework 4.5可在中使用,以支援舊版程式碼; 不過,新的非同步方法( ReadAsync例如、 CopyToAsync WriteAsync、和FlushAsync)可以協助您更輕鬆地執行非同步 i/o 作業。These methods are still available in the .NET Framework 4.5.NET Framework 4.5 to support legacy code; however, the new async methods, such as ReadAsync, WriteAsync, CopyToAsync, and FlushAsync, help you implement asynchronous I/O operations more easily.

呼叫EndRead以判斷從資料流程讀取的位元組數目。Call EndRead to determine how many bytes were read from the stream.

EndRead可以在每個IAsyncResult BeginRead上呼叫一次。EndRead can be called once on every IAsyncResult from BeginRead.

這個方法會封鎖,直到 I/O 作業完成為止。This method blocks until the I/O operation has completed.