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

定義

開始非同步的讀取作業。Begins an asynchronous read operation. 請考慮改用 ReadAsync(Byte[], Int32, Int32, CancellationToken)Consider using ReadAsync(Byte[], Int32, Int32, CancellationToken) instead.

public:
 override IAsyncResult ^ BeginRead(cli::array <System::Byte> ^ array, int offset, int numBytes, AsyncCallback ^ userCallback, System::Object ^ stateObject);
public override IAsyncResult BeginRead (byte[] array, int offset, int numBytes, AsyncCallback userCallback, object stateObject);
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

參數

array
Byte[]

要讀取資料的緩衝區。The buffer to read data into.

offset
Int32

array 中要開始讀取的位元組位移。The byte offset in array at which to begin reading.

numBytes
Int32

要讀取的最大位元組數。The maximum number of bytes to read.

callback
AsyncCallback

在非同步讀取作業完成時所呼叫的方法。The method to be called when the asynchronous read operation is completed.

state
Object

使用者所提供的物件,其可以從其他要求中區分出這個特定非同步讀取的要求。A user-provided object that distinguishes this particular asynchronous read request from other requests.

傳回

物件,參考非同步讀取。An object that references the asynchronous read.

例外狀況

陣列長度減去 offset 會小於 numBytesThe array length minus offset is less than numBytes.

arraynullarray is null.

offsetnumBytes 是負數。offset or numBytes is negative.

在超過檔案結尾處嘗試了非同步讀取。An asynchronous read was attempted past the end of the file.

適用於