System.IO.Pipes.PipeStream.EndRead Method

Ends a pending asynchronous read request.

Syntax

public override int EndRead (IAsyncResult asyncResult)

Parameters

asyncResult
The reference to the pending asynchronous request.

Returns

The number of bytes that were read. A return value of 0 indicates the end of the stream (the pipe has been closed).

Remarks

This method returns the number of bytes read into the byte array specified by the earlier call to PipeStream.BeginRead(Byte[], int, int, AsyncCallback, object).

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