Async await vs GetAwaiter().GetResult() and callback

后端 未结 1 459
情话喂你
情话喂你 2020-12-05 17:41

I am trying to find the best practice for one of my project. It is a typical WPF application with a UI that displays a list of items and there is a data service that returns

相关标签:
1条回答
  • 2020-12-05 18:18

    You should use the async and await keywords all the way up, or you shouldn't use async at all.

    Your second option is not really asynchronous. It's calling an asynchronous operation and blocking on it synchronously with task.GetAwaiter().GetResult(). On top of being very complicated it's not asynchronous and may lead to deadlocks.

    0 讨论(0)
提交回复
热议问题