3 ms·
I have been a C# developer for a while as well now and I'm not sure if this is true: "Use of async void in ASP.NET Core applications is ALWAYS bad. " Dependin
by jdthedisciple 5y ago
I have been a C# developer for a while as well now and I'm not sure if this is true:
"Use of async void in ASP.NET Core applications is ALWAYS bad. "
Depending on the context, it can even be recommended to do async void. See Stephen Cleary's brilliant explanation of this: https://blog.stephencleary.com/2012/02/async-and-await.html https://blog.stephencleary.com/2012/02/async-and-await.html
Edit: The correct link is this, see first table column exceptions: https://docs.microsoft.com/en-us/archive/msdn-magazine/2013/march/async-await-best-practices-in-asynchronous-programming https://docs.microsoft.com/en-us/archive/msdn-magazine/2013/...
- Avalaxy 5y ago> it can even be recommended to do async void I don't see this reflected in the linked article at all. Aren't you confusing async void with async Task?
- fabian2k 5y agoAn exception in an async void function will crash your entire ASP.NET Core application. There is no reason at all to use these in ASP.NET Core, always use Task or ValueTask as the return type of your async functions.
- thrower123 5y agoThere are still event handlers. You just have to always remember to always wrap async void methods with try { ... } catch (Exception ex){ ...}
- deleted 5y ago[deleted]