System.IO.Pipes.PipeStream.BeginRead Method

Begins an asynchronous read operation.

Syntax

public override IAsyncResult BeginRead (byte[] buffer, int offset, int count, AsyncCallback callback, object state)

Parameters

buffer
The buffer to read data into.
offset
The byte offset in buffer at which to begin reading.
count
The maximum number of bytes to read.
callback
The method to call when the asynchronous read operation is completed.
state
A user-provided object that distinguishes this particular asynchronous read request from other requests.

Returns

An IAsyncResult object that references the asynchronous read.

Remarks

Pass the returned IAsyncResult object to the PipeStream.EndRead(IAsyncResult) method to determine how many bytes were read and to release operating system resources used for reading. PipeStream.EndRead(IAsyncResult) must be called once for every call to PipeStream.BeginRead(Byte[], int, int, AsyncCallback, object). This can be done either in the same code that called PipeStream.BeginRead(Byte[], int, int, AsyncCallback, object) or in a callback that is passed to PipeStream.BeginRead(Byte[], int, int, AsyncCallback, object).

Use the PipeStream.CanRead property to determine whether the current System.IO.Pipes.PipeStream object supports read operations.

If the pipe is closed or an invalid argument is passed to PipeStream.BeginRead(Byte[], int, int, AsyncCallback, object), the appropriate exceptions are raised immediately. Errors that occur during an asynchronous read request occur on the thread pool thread that is performing the request. The exceptions are raised when the code calls the PipeStream.EndRead(IAsyncResult) method.

Requirements

Namespace: System.IO.Pipes
Assembly: System.Core (in System.Core.dll)
Assembly Versions: 4.0.0.0