Download this episode
Async Tip #1: Async void is for top-level event-handlers only, and event-like things. Don't use it elsewhere in your code.
Slides are available on Lucian's blog.
Async void is a "fire-and-forget" mechanism: the caller is unable to know when an async void has finished, and the caller is unable to catch any exceptions from it. The only case where this kind of fire-and-forget is appropriate is in top-level event-handlers. Every other async method in your code should return "async Task".
This video goes into some more difficult cases like the Win8 example "overrides async void LoadSettings()". Here you're overriding the method, and can't change the signature, and can't return a Task from it. The solution is to return a Task some other way, like through a field.
The video also talks about the thorny problem of async void lambdas. WHENEVER you see an async lambda, you need to verify whether it will be a void-returning or Task-returning lambda.
Available formats for this video:
Actual format may change based on video formats available and browser capability.
Comments have been closed since this content was published more than 30 days ago, but if you'd like to send us feedback you can Contact Us.