IsolatedStorageFileStream.BeginRead 方法

定義

開始非同步讀取。

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

參數

bufferarray
Byte[]

要讀取資料的緩衝區。

offset
Int32

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

numBytes
Int32

要讀取的最大位元組數。

userCallback
AsyncCallback

在完成非同步讀取作業時呼叫的方法。 這是選擇性參數。

stateObject
Object

非同步讀取的狀態。

傳回

IAsyncResult 物件,表示可能還在暫止中的非同步讀取。 這個 IAsyncResult 必須傳遞給這個資料流的 EndRead(IAsyncResult) 方法,以判斷有多少位元組被讀取。 若要做到這點,可以使用與呼叫 BeginRead(Byte[], Int32, Int32, AsyncCallback, Object) 相同的程式碼,或者在傳遞至 BeginRead(Byte[], Int32, Int32, AsyncCallback, Object) 的回呼中做到。

例外狀況

在超過檔案結尾處嘗試了非同步讀取。

備註

當您發出異步讀取或寫入時,數據流中的目前位置會更新,而不是 I/O 作業完成時。

您必須使用 呼叫 EndReadIAsyncResult 以找出讀取的位元元組數目。

適用於