That's NOT How Async And Await Works in .NET!

preview_player
Показать описание
Async and await in .NET is something so common, yet a lot of people fail to understand how it works and what problems does it solve. It's sad that even "influencers" spread misleading information in infographics tailored mostly for views and engagement than for knowledge sharing. In this video I will demystify once and for all how async and await works in .NET and what problem it solves.
#dotnet

Join this channel to get source code access and other perks:

Рекомендации по теме
Комментарии
Автор

For everybody that brings the authority argument that the picture is from the Microsoft docs. Please note that in the Microsoft docs, the picture is used in a sub-section called "Start tasks concurrently", so it's used to describe concurrency/parralelization, not to illustrate the the difference between sync and async programming.

Codewrinkles
Автор

Good points! I would summarize that async programming is about keeping CPU cores as much busy as possible without waiting for background tasks, in a application that can process many asynchronous requests/events.

ceztko
Автор

Good explanation!

Async await is extremly important in client-side web apps where we only have one thread, for example in Blazor. If we perform some calculations that take a lot of time, we will have a frozen UI. By awaiting some of these things we can allow the UI to refresh and update in between long calculations, for example for showing progress. In blazor this is actually that common that we manually add some await Task.Delay(1); in between to give the UI some time to catch up. Without these calls the browser will just act frozen and may even report "not responding"

matheosmattsson
Автор

So you're saying Microsoft is fundamentally wrong about async/await? Because the image at the start of the clip is from a Microsoft article titled: "Asynchronous programming with async and await"

MilanJovanovicTech
Автор

Great post, I think it's worth mentioning, that async leverages managing IO operations(external processes) to not block the main execution thread, while Parallelism is used for CPU-heavy tasks(in-process).

olegsuprun
Автор

Thank you for this visual code explanation. I saw the post and something kept bothering me. I'm not the best coder by any means. This clears things up for me.❤

abbylynn
Автор

THIS is great because when i googled async /await i too saw that visual. this is very useful for a beginner . can you do a project that walks us thru real world handyness of these async/await functions for those who dont get to use it at work or havent found a job yet where they need to use it

dddrrr
Автор

It was a great explanation. Thanks for sharing it. I want to mention that understanding how exactly async/await is handled by the state machine underhood in .Net can help in understanding it better.

Rhazizi
Автор

It's like going to a restaurant and placing a large order and customers who ordered after you with small orders get their food before you do.

raymondfinton
Автор

Thank you so much! I happened upon that Breakfast Code example and was stuck trying to figure out why it didn't work asynchronously for me. Again, much appreciated!

michaelramseybooks
Автор

Why do I need asynchrony at all if the application is interface less and interrupt-free, and the standard threads are interrupted at any time as it is?

ltrnofy
Автор

how do i is this when i don't want to use the buildin database and use my own database, where I use roles and useraccounts ?

JoVanVosselen
Автор

Thank you very much! Only after YOU i understand this theme! I love you! Thank you again!😘

Pozetivchil
Автор

Your videos are great, it's always good to hear and learn from you. But I can't comment in chat in your live stream videos, it says subscriber only mode. What does that mean?

dev.hmehedi
Автор

What's a good way to deal with Task.WhenAll exceptions?

slowjocrow
Автор

All separated defined async methods are non blocking and program continues with next line. But having a bunch async methods together as a parallel in the main thread then the program will wait until all methods are completed, but are running async in the main thread. Therefor the next line after parallel invocation will not start until all parallel async methods are completed.

teceffect
Автор

Please make video about typical scenarious, where we should user Task.WhenAll !

bxerzxu
Автор

@everyone

It looks like this video did more bad then good ... By reading comments seems like lots people still don't know how async await works and what problem it solves. Please watch recent video that explains aysnc/await in detail:

Writing async/await from scratch in C# with Stephen Toub

This video will answer all your questions about concurrency, async/await and threading, which in the docs is mentioned and explained correctly, if you bother reading the docs from start to finish.

activex
Автор

I think you're confusing about async and parallel here 😁. Correct me if I'm wrong but,
Synchronize programming is when you execute some sort of IO operation and Wait for the IO Thread to finish and the continue.
Parallel programming is handled using Parallel library it's the fact that you shank a big workload into different CPUs to be executed at the same time then collect the result and return it or what ever.
Async programming in the other hand, is the fact that you fire something in a Task and don't wait for the IO Thread to finish its work the Thread actually returns into the ThreadPool, the big difference with Parallel programming, async programming can be executed if your compute have one single CPU and parallel programming is executed into multiple CPUs.

Yogs
Автор

Concurrency is doing other tasks while we are waiting for a given task. So in this case, the docs are right, a not-a-blocked thread can do other tasks concurrently while given task completes.

activex