PipeStream.BeginRead(Byte[], Int32, Int32, AsyncCallback, Object) 方法

定義

開始非同步的讀取作業。

public:
 override IAsyncResult ^ BeginRead(cli::array <System::Byte> ^ buffer, int offset, int count, AsyncCallback ^ callback, System::Object ^ state);
public override IAsyncResult BeginRead (byte[] buffer, int offset, int count, AsyncCallback? callback, object? state);
public override IAsyncResult BeginRead (byte[] buffer, int offset, int count, AsyncCallback callback, object state);
[System.Security.SecurityCritical]
public override IAsyncResult BeginRead (byte[] buffer, int offset, int count, AsyncCallback callback, object state);
override this.BeginRead : byte[] * int * int * AsyncCallback * obj -> IAsyncResult
[<System.Security.SecurityCritical>]
override this.BeginRead : byte[] * int * int * AsyncCallback * obj -> IAsyncResult
Public Overrides Function BeginRead (buffer As Byte(), offset As Integer, count As Integer, callback As AsyncCallback, state As Object) As IAsyncResult

參數

buffer
Byte[]

要讀取資料的緩衝區。

offset
Int32

buffer 中要開始讀取的位元組位移。

count
Int32

要讀取的最大位元組數。

callback
AsyncCallback

在完成非同步讀取作業時呼叫的方法。

state
Object

使用者所提供的物件,其可以從其他要求中區分出這個特定非同步讀取的要求。

傳回

IAsyncResult 物件,參考非同步讀取。

屬性

例外狀況

buffernull

offset 小於 0。

-或-

count 小於 0。

count 大於 buffer 中的可用位元組數目。

管道已關閉。

管道不支援讀取作業。

管道已中斷連接、正在等候連接,或尚未設定控制代碼。

管道已中斷,或發生另一個 I/O 錯誤。

備註

將傳 IAsyncResult 回的對象傳遞至 EndRead 方法,以判斷已讀取的位元元組數目,以及釋放用於讀取的作業系統資源。 EndRead 每次呼叫 BeginRead都必須呼叫一次。 這可以在呼叫 BeginRead 的相同程序代碼中完成,或在傳遞至 BeginRead的回呼中完成。

CanRead使用屬性來判斷目前PipeStream物件是否支援讀取作業。

如果管道已關閉或傳遞無效的自變數, BeginRead則會立即引發適當的例外狀況。 異步讀取要求期間發生的錯誤發生在執行要求的線程集區線程上。 當程式代碼呼叫 EndRead 方法時,就會引發例外狀況。

適用於