Try Catch aspect on async void method doesn't work
See original GitHub issueHi, we have another problem with try/catch aspect described here
https://github.com/ArxOne/MrAdvice/issues/118
It just doesn’t come to catch block in case when unhandeled exception occurs in “async void” method:
public async void AddWhatever23()
{
throw new Exception("");
}
with public async Task AddWhatever23() - all OK.
Any ideas of handling such case?
Issue Analytics
- State:
- Created 6 years ago
- Comments:17 (10 by maintainers)
Top Results From Across the Web
Why I couldn't catch the exception in async function that ...
1 Answer. Any time you have async void , you're basically breaking the ability to correctly signal completion and failure; the only way...
Read more >async void – How to Tame the Asynchronous Nightmare
We are unable to (traditionally) wrap calls to async void methods in try / catch blocks and actually have them work as we'd...
Read more >Async/Await - Best Practices in Asynchronous Programming
Void -returning async methods have a specific purpose: to make asynchronous event handlers possible. It is possible to have an event handler that...
Read more >Why is async void bad? : r/csharp
Async methods returning void don't provide an easy way to notify the calling code that they've completed. It's easy to start several async...
Read more >How To Do @Async in Spring
Self-invocation — calling the async method from within the same class — won't work. The reasons are simple: The method needs to be...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I replied 😉
@dougcunha you missed the point in my answer; it was a smiling emoji. So no problem!