-
Notifications
You must be signed in to change notification settings - Fork 933
-
Hi. I saw the examples how to use nHibernate 5 async features, something like this.
async Task<Item> GetItems(){
return await _session.ListAsync();
}
Why should to use async/await instead of just?
Task<Item> GetItems(){
return _session.ListAsync();
}
It lets us avoid the async/await overhead. Or maybe are any other reasons to do like in the first example.
I have read the documentation but didn't find an answer. Maybe are any limitations and the second example will not work?
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 2 comments
-
It does not matter as long as you do not forget to await the final call like this:
var items = await GetItems();
Beta Was this translation helpful? Give feedback.
All reactions
-
@stcom77
I really like explanation given here https://www.reddit.com/r/csharp/comments/9igzbf/whats_the_difference_between_awaiting_a_task_vs/
If you want more technical details check https://blog.stephencleary.com/2016/12/eliding-async-await.html
Beta Was this translation helpful? Give feedback.