有没有办法通知 C# 编译器我不想等待异步调用?

Is there a way to inform the C# compiler that I don't want to await an asyncronous call?

给定如下代码(用于测试):

            tcpListener = new TcpListener(IPAddress.Any, port);
            tcpListener.Start();
            while (!cancellation.IsCancellationRequested)
            {
                var client = await tcpListener.AcceptTcpClientAsync();
                //Monitor services TCP messages to this client
                var monitor = new Monitor(client);
                monitor.MonitorAsync(cancellation.Token);
            }

我明确地想在MonitorAsyncawait因为我希望每个监视器并行运行,但是Visual Studio 警告我(当然是正确的)代码执行将继续而不等待 MonitorAsync 完成。

我更愿意避免编译器警告,并将它们视为我正在做事情的标志 wrong/unwisely。那么有没有一种 'proper' 方法可以满足编译器的故意行为?

只需分配任务并使用 discard operator:

忽略它
_ = monitor.MonitorAsync(cancellation.Token);