Difference between await & GetAwaiter()/GetResult()
I'm actually doing a simple task that checks if a role exists in the database and create it if the role doesn't exists.
Code:
Here's how it looks like with await:
6 Replies
.GetAwaiter().GetResult()
is blocking
The one and only proper way to call asynchronous code is with await
No maybes, no perhapses$deadlock
Don't Block on Async Code
This is a problem that is brought up repeatedly on the forums and Stack Overflow. I think it’s the most-asked question by async newcomers once they’ve learned the basics.
Also see $nothread
There Is No Thread
This is an essential truth of async in its purest form: There is no thread.
Thanks a lot.
I'll read about it and then modify the code.