BeginRead Method
See Also 
SourceCode.IO Namespace > SizeLimitedStream Class : BeginRead Method



buffer
The buffer to read the data into.
offset
The byte offset in buffer at which to begin writing data read from the stream.
count
The maximum number of bytes to read.
callback
An optional asynchronous callback, to be called when the read is complete.
state
A user-provided object that distinguishes this particular asynchronous read request from other requests.

Glossary Item Box

Begins an asynchronous read operation. (Consider using System.IO.Stream.ReadAsync(System.Byte[],System.Int32,System.Int32) instead; see the Remarks section.)

Syntax

Visual Basic (Declaration) 
Public Overrides Function BeginRead( _
   ByVal buffer() As Byte, _
   ByVal offset As Integer, _
   ByVal count As Integer, _
   ByVal callback As AsyncCallback, _
   ByVal state As Object _
) As IAsyncResult
Visual Basic (Usage)Copy Code
Dim instance As SizeLimitedStream
Dim buffer() As Byte
Dim offset As Integer
Dim count As Integer
Dim callback As AsyncCallback
Dim state As Object
Dim value As IAsyncResult
 
value = instance.BeginRead(buffer, offset, count, callback, state)
C# 
public override IAsyncResult BeginRead( 
   byte[] buffer,
   int offset,
   int count,
   AsyncCallback callback,
   object state
)

Parameters

buffer
The buffer to read the data into.
offset
The byte offset in buffer at which to begin writing data read from the stream.
count
The maximum number of bytes to read.
callback
An optional asynchronous callback, to be called when the read is complete.
state
A user-provided object that distinguishes this particular asynchronous read request from other requests.

Return Value

An System.IAsyncResult that represents the asynchronous read, which could still be pending.

Exceptions

ExceptionDescription
System.IO.IOExceptionAttempted an asynchronous read past the end of the stream, or a disk error occurs.
System.ArgumentExceptionOne or more of the arguments is invalid.
System.ObjectDisposedExceptionMethods were called after the stream was closed.
System.NotSupportedExceptionThe current Stream implementation does not support the read operation.

Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also