Redigera

Dela via


ClientWebSocket.ReceiveAsync Method

Definition

Overloads

ReceiveAsync(ArraySegment<Byte>, CancellationToken)

Receives data on ClientWebSocket as an asynchronous operation.

ReceiveAsync(Memory<Byte>, CancellationToken)

Receives data on ClientWebSocket as an asynchronous operation.

ReceiveAsync(ArraySegment<Byte>, CancellationToken)

Source:
ClientWebSocket.cs
Source:
ClientWebSocket.cs
Source:
ClientWebSocket.cs

Receives data on ClientWebSocket as an asynchronous operation.

public:
 override System::Threading::Tasks::Task<System::Net::WebSockets::WebSocketReceiveResult ^> ^ ReceiveAsync(ArraySegment<System::Byte> buffer, System::Threading::CancellationToken cancellationToken);
public override System.Threading.Tasks.Task<System.Net.WebSockets.WebSocketReceiveResult> ReceiveAsync (ArraySegment<byte> buffer, System.Threading.CancellationToken cancellationToken);
override this.ReceiveAsync : ArraySegment<byte> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Net.WebSockets.WebSocketReceiveResult>
Public Overrides Function ReceiveAsync (buffer As ArraySegment(Of Byte), cancellationToken As CancellationToken) As Task(Of WebSocketReceiveResult)

Parameters

buffer
ArraySegment<Byte>

The buffer to receive the response.

cancellationToken
CancellationToken

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

Returns

The task object representing the asynchronous operation.

Exceptions

The cancellation token was canceled. This exception is stored into the returned task.

Remarks

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. Issuing multiple receives at the same time is not supported and will result in an undefined behavior. You should serialize receive operations via whatever mechanism works best for you, for example, by using a lock or a semaphore.

Applies to

ReceiveAsync(Memory<Byte>, CancellationToken)

Source:
ClientWebSocket.cs
Source:
ClientWebSocket.cs
Source:
ClientWebSocket.cs

Receives data on ClientWebSocket as an asynchronous operation.

public:
 override System::Threading::Tasks::ValueTask<System::Net::WebSockets::ValueWebSocketReceiveResult> ReceiveAsync(Memory<System::Byte> buffer, System::Threading::CancellationToken cancellationToken);
public override System.Threading.Tasks.ValueTask<System.Net.WebSockets.ValueWebSocketReceiveResult> ReceiveAsync (Memory<byte> buffer, System.Threading.CancellationToken cancellationToken);
override this.ReceiveAsync : Memory<byte> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<System.Net.WebSockets.ValueWebSocketReceiveResult>
Public Overrides Function ReceiveAsync (buffer As Memory(Of Byte), cancellationToken As CancellationToken) As ValueTask(Of ValueWebSocketReceiveResult)

Parameters

buffer
Memory<Byte>

The region of memory to receive the response.

cancellationToken
CancellationToken

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

Returns

The task object representing the asynchronous operation.

Exceptions

The cancellation token was canceled. This exception is stored into the returned task.

Remarks

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. Issuing multiple receives at the same time is not supported and will result in an undefined behavior. You should serialize receive operations via whatever mechanism works best for you, for example, by using a lock or a semaphore.

Applies to