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

定义

开始异步读操作。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> ^ buffer, int offset, int count, AsyncCallback ^ callback, System::Object ^ state);
public override IAsyncResult BeginRead (byte[] buffer, int offset, int count, AsyncCallback callback, object state);
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

参数

array
Byte[]

将数据读入的缓冲区。The buffer to read data into.

offset
Int32 Int32 Int32 Int32

array 中的字节偏移量,从此处开始读取。The byte offset in array at which to begin reading.

numBytes
Int32 Int32 Int32 Int32

最多读取的字节数。The maximum number of bytes to read.

callback
AsyncCallback AsyncCallback AsyncCallback AsyncCallback

异步读操作完成后调用的方法。The method to be called when the asynchronous read operation is completed.

state
Object Object Object 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.

尝试在文件的末尾后进行异步读取。An asynchronous read was attempted past the end of the file.

适用于