Visual Studio emits a warning for this code (\'because this call is not awaited, execution of the current method continues before the call is completed\').
s
It's extremely rare to have a true fire-and-forget operation; that is, an operation where:
Particularly with the last of these; most so-called "fire-and-forget" operations are not actually fire-and-forget because some action needs to be taken if it doesn't succeed.
That said, there are a few situations where a true fire-and-forget is applicable.
I prefer to use async Task
and avoid the compiler warning by assigning the task to an otherwise unused variable:
var _ = FireAndForget();
async Task
methods are more reusable and testable than async void
methods.
However, I wouldn't throw a fit if a developer on my team just used async void
instead.