WebSocket.CloseAsync(WebSocketCloseStatus, String, CancellationToken) 方法

定義

以非同步作業使用 WebSocket 通訊協定規格第 7 節中所定義的關閉信號交換,關閉 WebSocket 連接。Closes the WebSocket connection as an asynchronous operation using the close handshake defined in the WebSocket protocol specification section 7.

public:
 abstract System::Threading::Tasks::Task ^ CloseAsync(System::Net::WebSockets::WebSocketCloseStatus closeStatus, System::String ^ statusDescription, System::Threading::CancellationToken cancellationToken);
public abstract System.Threading.Tasks.Task CloseAsync (System.Net.WebSockets.WebSocketCloseStatus closeStatus, string statusDescription, System.Threading.CancellationToken cancellationToken);
abstract member CloseAsync : System.Net.WebSockets.WebSocketCloseStatus * string * System.Threading.CancellationToken -> System.Threading.Tasks.Task

參數

closeStatus
WebSocketCloseStatus

指出關閉 WebSocket 連線的原因。Indicates the reason for closing the WebSocket connection.

statusDescription
String

指定易懂的連線結束原因說明。Specifies a human readable explanation as to why the connection is closed.

cancellationToken
CancellationToken

可以用來散佈應該取消作業之通知的語彙基元。The token that can be used to propagate notification that operations should be canceled.

傳回

工作物件,表示非同步作業。The task object representing the asynchronous operation.

備註

這項作業不會封鎖。This operation will not block. 傳回的 Task 物件將在 WebSocket 關閉後完成。The returned Task object will complete after the WebSocket has been closed.

這個方法會使用websocket 通訊協定規格第7節中所定義的關閉信號交換來關閉 WebSocket 連線。This method closes the WebSocket connection using the close handshake defined in the WebSocket protocol specification section 7.

適用於