Muokkaa

Jaa


QuicConnection.CloseAsync(Int64, CancellationToken) Method

Definition

Closes the connection with the application provided-code.

public System.Threading.Tasks.ValueTask CloseAsync (long errorCode, System.Threading.CancellationToken cancellationToken = default);
member this.CloseAsync : int64 * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask
Public Function CloseAsync (errorCode As Long, Optional cancellationToken As CancellationToken = Nothing) As ValueTask

Parameters

errorCode
Int64

An application-provided code with the reason for closure.

cancellationToken
CancellationToken

A cancellation token that can be used to cancel the asynchronous operation.

Returns

An asynchronous task that completes when the connection is closed.

Exceptions

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

Remarks

Closing the connection is not graceful in regards to its streams. Calling CloseAsync(Int64, CancellationToken) will immediately close all streams associated with this connection. Make sure that all streams have been closed and all their data consumed before calling this method. Otherwise, all the data that was received but not yet consumed will be lost.

If CloseAsync(Int64, CancellationToken) is not called before disposing the connection, the DefaultCloseErrorCode will be used by DisposeAsync() to close the connection.

Applies to

See also