DEV Community

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

Collapse
 
_siva_sankar profile image
Siva Sankaran S • Edited

Apart from //"not awaiting inner methods"// What'll happen if we are not awaiting a method ?

Calling an async method without await (and without awaiting it's returned task) will not have any impact in asynchronous nature of code . Will it ?

One disadvantage is exception can't be handled if we are not awaiting. Can anyone share what else if we aren't awaiting?

Collapse
 
paulafahmy profile image
Paula Fahmy

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