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

定义

开始异步读。Begins an asynchronous read.

public:
 override IAsyncResult ^ BeginRead(cli::array <System::Byte> ^ buffer, int offset, int numBytes, AsyncCallback ^ userCallback, System::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
Public Overrides Function BeginRead (buffer As Byte(), offset As Integer, numBytes As Integer, userCallback As AsyncCallback, stateObject As Object) As IAsyncResult

参数

buffer
Byte[]

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

offset
Int32

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

numBytes
Int32

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

userCallback
AsyncCallback

异步读操作完成后调用的方法。The method to call when the asynchronous read operation is completed. 此参数可选。This parameter is optional.

stateObject
Object

异步读的状态。The status of the asynchronous read.

返回

表示可能仍处于挂起状态的异步读取的 IAsyncResult 对象。An IAsyncResult object that represents the asynchronous read, which is possibly still pending. IAsyncResult 必须传递到该流的 EndRead(IAsyncResult) 方法以确定读取的字节数。This IAsyncResult must be passed to this stream's EndRead(IAsyncResult) method to determine how many bytes were read. 这可以通过调用 BeginRead(Byte[], Int32, Int32, AsyncCallback, Object) 的相同代码来完成,或在传递给 BeginRead(Byte[], Int32, Int32, AsyncCallback, Object) 的回调中完成。This can be done either by the same code that called BeginRead(Byte[], Int32, Int32, AsyncCallback, Object) or in a callback passed to BeginRead(Byte[], Int32, Int32, AsyncCallback, Object).

例外

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

注解

发出异步读取或写入操作时,将更新流中的当前位置,而不是在 i/o 操作完成时进行更新。The current position in the stream is updated when you issue the asynchronous read or write, not when the I/O operation completes.

必须通过此 IAsyncResult 调用 EndRead,以确定读取的字节数。You must call EndRead with this IAsyncResult to find out how many bytes were read.

适用于