Rediger

Del via


PipeStream.EndRead(IAsyncResult) Method

Definition

Ends a pending asynchronous read request.

public:
 override int EndRead(IAsyncResult ^ asyncResult);
public override int EndRead (IAsyncResult asyncResult);
[System.Security.SecurityCritical]
public override int EndRead (IAsyncResult asyncResult);
override this.EndRead : IAsyncResult -> int
[<System.Security.SecurityCritical>]
override this.EndRead : IAsyncResult -> int
Public Overrides Function EndRead (asyncResult As IAsyncResult) As Integer

Parameters

asyncResult
IAsyncResult

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).

Attributes

Exceptions

asyncResult is null.

asyncResult did not originate from a BeginRead(Byte[], Int32, Int32, AsyncCallback, Object) method on the current stream.

The stream is closed or an internal error has occurred.

Remarks

This method returns the number of bytes read into the byte array specified by the earlier call to BeginRead.

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

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

If the pipe is closed or an invalid argument is passed to BeginRead, 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 EndRead method.

Applies to