ClientWebSocket.ReceiveAsync Method (ArraySegment<Byte>, CancellationToken)

.NET Framework (current version)

Receive data on ClientWebSocket as an asynchronous operation.

Namespace:   System.Net.WebSockets
Assembly:  System (in System.dll)

public override Task<WebSocketReceiveResult> ReceiveAsync(
	ArraySegment<byte> buffer,
	CancellationToken cancellationToken


Type: System.ArraySegment<Byte>

The buffer to receive the response.

Type: System.Threading.CancellationToken

A cancellation token used to propagate notification that this operation should be canceled.

Return Value

Type: System.Threading.Tasks.Task<WebSocketReceiveResult>

Returns Task<TResult>.

The task object representing the asynchronous operation.

This operation will not block. The returned Task<TResult> object will complete after the receive request on the ClientWebSocket instance has completed.

Exactly one send and one receive is supported on each ClientWebSocket object in parallel.

.NET Framework
Available since 4.5
Return to top