DEV Community

Discussion on: Asynchronous C#: Cherry on the top 🍒 (Tips and Tricks)

Collapse
paulafahmy profile image
Paula Fahmy Author

Yes, correct, by the time the exception is thrown, the program would've passed the point of catching it.
If you absolutely need to run synchronously and for some reason don't want to use "await", you could use ".GetAwaiter().GetResult();" to be able to catch the exception gracefully, otherwise, the exception would not be thrown.
Here is a snippet if you want to try it out dotnetfiddle.net/uXBsWT