NetworkStream.EndRead(IAsyncResult) 方法
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
處理非同步讀取的結束。
public:
override int EndRead(IAsyncResult ^ asyncResult);
C#
public override int EndRead (IAsyncResult asyncResult);
override this.EndRead : IAsyncResult -> int
Public Overrides Function EndRead (asyncResult As IAsyncResult) As Integer
- asyncResult
- IAsyncResult
IAsyncResult,表示非同步呼叫。
從 NetworkStream 讀取的位元組數。
asyncResult
參數為 null
。
重要
這是相容性 API,不建議使用 APM (Begin / End) 方法進行新的開發。 請改用以工作為基礎的對等專案。
方法 EndRead 會完成 方法所啟動的 BeginRead 讀取作業。 您必須傳遞 IAsyncResult 比 BeginRead 對呼叫所建立的 。 EndRead 將會封鎖呼叫線程,直到作業完成為止。
作業會讀取可用的數據量,最多為 參數所 size
指定的位元元組數目。
備註
如果您收到 IOException,請檢查 InnerException 屬性,以判斷它是否由 SocketException所造成。 如果是,請使用 ErrorCode 屬性來取得特定的錯誤碼。
產品 | 版本 |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |