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