MemoryStream: BeginRead

BeginRead

Begins an asynchronous buffer read. For a MemoryStream, calling an asynchronous buffer read is identical to calling ReadBlock.



 Public Function BeginRead(
	  ByRef Buffer ( ) As Byte,
	  ByVal Offset As Long,
	  ByVal Count As Long,
	  Optional ByVal Callback As AsyncCallback,
	  Optional ByRef State As Variant ) As IAsyncResult

Parameters

Buffer
[ByRef] Byte. The destination array to copy the bytes into.
Offset
[ByVal] Long. The index in Buffer to begin copying to.
Count
[ByVal] Long. The maximum number of bytes to copy.
Callback
[ByVal] Optional. AsyncCallback. A listening object to be notified that the read is finished.
State
[ByRef] Optional. Variant. User data that can be carried within the IAsyncResult object returned.

Return Values

IAsyncResult -  An IAsyncResult object used to identify the corrisponding Endread and report information about the buffer read.

Remarks

Since the stream is directly stored and accessed in memory, there is no waiting for reads to occur. The BeginRead method works identical to the ReadBlock method in terms of immediately reading stream data into the Buffer.

When defining the Count for the number of maximum bytes to be read, if the stream does not have enough bytes, the read will copy less bytes than Count.

If an exception has occurred during the read, it will not be thrown until the EndRead is executed.

See Also

Project CorLib Overview

Class MemoryStream Overview