Given code like the following (for testing):
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);
}
I explicitly do not want to await
on MonitorAsync
because I want each Monitor to run in parallel, however Visual Studio warns me (correctly of course) that code execution will continue without waiting for MonitorAsync
to complete.
I prefer to avoid compiler warnings and view them as a sign I'm doing things wrong/unwisely. So is there a 'proper' way to do this which will satisfy the compiler it is intentional behaviour?