I do like the way async/await works in C#, it only felt like a burden when my entire app was synchronous but once I started moving to async, it became easier and easier.
With some of the examples in your post though, I would be careful with how they use async. Things like async void, returning a task without awaiting, and calling task.Result can have different issues in different circumstances.
Here is a good guide of when and how to use async/await which covers how/why some of those aspects can be bad: github.com/davidfowl/AspNetCoreDia...
That guide might be aimed at ASP.Net Core however many (maybe all) aspects are still relevant outside of it.
Thanks for letting me know... for the sake of completing the article I didn't look carefully into the codes, I just copied and pasted couple of examples from various places and mentioned their sources; I will update the examples soon.
Some of these things about async/await aren't all that obvious and different understanding of how to use it likely changed over time. The people that probably wrote the example code probably had it based on old information.
One of the things that gets me still with the async/await pattern is whether I need to call ConfigureAwait(false) or not - there seems to be a lot of different opinions about it online from a variety of people smarter than me.
C# is moving a bit fast that I feel sometimes it's burdensome to catch up with their latest updates.
I feel the same way about JavaScript!
As much as some of the new features that are being released (in JS, C#, CSS etc) are helpful and solves certain problems, there are some cases where I just look at it and wonder how we got here as it doesn't look easier/better than what existed.
I do like the way async/await works in C#, it only felt like a burden when my entire app was synchronous but once I started moving to async, it became easier and easier.
With some of the examples in your post though, I would be careful with how they use async. Things like
async void
, returning a task without awaiting, and callingtask.Result
can have different issues in different circumstances.Here is a good guide of when and how to use async/await which covers how/why some of those aspects can be bad: github.com/davidfowl/AspNetCoreDia...
That guide might be aimed at ASP.Net Core however many (maybe all) aspects are still relevant outside of it.
Thanks for letting me know... for the sake of completing the article I didn't look carefully into the codes, I just copied and pasted couple of examples from various places and mentioned their sources; I will update the examples soon.
No problem 🙂
Some of these things about async/await aren't all that obvious and different understanding of how to use it likely changed over time. The people that probably wrote the example code probably had it based on old information.
One of the things that gets me still with the async/await pattern is whether I need to call
ConfigureAwait(false)
or not - there seems to be a lot of different opinions about it online from a variety of people smarter than me.Yeah, I still remember the first days I was cluelessly reading different articles about async C# and mixing new code with old one :D
C# is moving a bit fast that I feel sometimes it's burdensome to catch up with their latest updates.
I feel the same way about JavaScript!
As much as some of the new features that are being released (in JS, C#, CSS etc) are helpful and solves certain problems, there are some cases where I just look at it and wonder how we got here as it doesn't look easier/better than what existed.
JavaScript is a whole different story 😆
They just add all sort of keywords and features into the language just to feel "Oh, JavaScript can do that too" 😑