question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Try Catch aspect on async void method doesn't work

See original GitHub issue

Hi, 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:open
  • Created 6 years ago
  • Comments:17 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
picrapcommented, Jan 9, 2019

I replied 😉

1reaction
picrapcommented, Oct 31, 2018

@dougcunha you missed the point in my answer; it was a smiling emoji. So no problem!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found