Mixing async-await with fire-and-forget approach
问题 I'm writing a websocket server using .NET's HttpListener class. Essentially, I've got a HandleListener() function which wait for clients to connect and yield each client to HandleClient(WebSocket client) . So I currently have: private async void HandleListener() { try { while (listener != null && listener.IsListening) { HttpListenerContext listenerContext = await listener.GetContextAsync(); WebSocketContext webSocketContext = await listenerContext.AcceptWebSocketAsync(subProtocol: null);