Hi folks. If you're enjoying this presentation, I also have a 5-hour course in Python covering Python's equivalent async and await as well as more. Check it out at training.talkpython.fm/courses/explore_async_python/async-in-python-with-threading-and-multiprocessing
@Euquila8 жыл бұрын
VB programmer here. I just switched from .net 4.0 to 4.5 and wanted to learn about async and await. I found your video exceptional. You really have a knack for teaching!
@LucasBatistussi12 жыл бұрын
Wow! This is the best "tutorial" about asynchronous programming I ever saw! Finally I understood what asynchronous tasks are and differences with parallel approach. Keep doing this kind of great work! Congratulations! Favorited.
@AlanDias1710 жыл бұрын
Best explanation I've ever found. We admire your work, dedication and competence.
@mikeckennedy10 жыл бұрын
Thank you!
@ValiRossi6 жыл бұрын
I agree. Good job.
@magnusdeus1238 жыл бұрын
Just halfway through your video Michael and have to express my gratitude. You've explained this subject much clearer than so many other instructors whose I've tried to follow; especially even those on some huge, well-funded, training sites. Thank you, particularly, for explaining the little bit about Tasks in the beginning - so many tutorials either seem too dated; keen on teaching C# 3.5 Thread-based programming patterns, or jump straight to async and await.
@mikeckennedy8 жыл бұрын
Thanks so much Ash!
@LouisWaweru2 жыл бұрын
@@mikeckennedy I agree, I was almost sad to see your more recent videos are on Python 😅
@mikeckennedy2 жыл бұрын
@@LouisWaweru thanks for the nice thoughts Louis.
@MattRothtauscher8 жыл бұрын
So old but still gold. Thanks for super easy understanding in that topic with going into detail. It really helped me understanding all of it :)
@mikeckennedy8 жыл бұрын
+Matt Rothtauscher Thanks, glad it helped you grok it!
@mikeckennedy11 жыл бұрын
Yes totally. The same stuff you see here applies. You just cannot touch the UI elements from the background threads so 1. Gather what you need. 2. Kick off the bg work. 3. The async / await keyword should bring you back to the ui thread on completion, then update the UI elements.
@Fean9rz10 жыл бұрын
I was having big problems finding a way to fix a bug in my logic. I had a while(true) { // stuff } and other code that had to be executed at the same time. This video with the async await Task.Delay(time), made my day!!! Thank very very much!
@pavansonty14 жыл бұрын
Great video. I went through lot of material/other videos. But couldnt exactly understand how async await works. Thanks a lot for clearing the confusions around async & await.
@mikeckennedy4 жыл бұрын
You're welcome. Thanks!
@dland20008 жыл бұрын
Great video. Really helpful. The Surface vs. iPad search was classic.
@danielschmid853011 жыл бұрын
Holy, that's what I call in-depth! I have been using the Thread and ThreadPool classes for a long time now and never really got around looking into that topic more thoroughly, but this has enlightended me so much! Everything is explained to the extent I need to update my applications using the await and async keywords and the Task-class, and get rid of the Thread and ThreadPool classes. Although I will profile the overhead Task has over ThreadPool, just for paranoia reasons. ;) Gonna share this.
@WoundedEgo10 жыл бұрын
I went to your website. What a great resource for us developers. Thanks!
@mikeckennedy12 жыл бұрын
Hi, Good question. You could use Parallel.ForEach but it would not have exactly the same effect. Using the await keyword on what is ultimately webclient.DownloadStringTaskAsyc() means we are just waiting on IO Completion ports. You'll see that the system doesn't actually create any more threads. ...
@OtRatsaphong8 жыл бұрын
Wow, Great tutorial!! I finally understand how to use async & await. Thanks for the clear explanation.
@UBOATss11 жыл бұрын
First of all thank you for this information...2nd to sum it all up its like having your software invading multiple cpu's :) with 'continue with' you literally keep feeding the invasion and re-supply with instructions...this is awesome thanks again! i come from multi threading in java...this is very powerful stuff
@pratapkv230510 жыл бұрын
Makes things crystal clear! Thanks Michael.
@yrajeshk53211 жыл бұрын
thanks Michael that was good introduction to the Asynchronous programming
@cvaldivia9310 жыл бұрын
Excellent video; thanks for sharing. You have a real gift for teaching.
@michor107 жыл бұрын
This was a really well done presentation. Thank you for sharing.
@KCAbramson8 жыл бұрын
Thanks for this. Wish i saw it back when it first came out! It's time to take the async thing more seriously like an adult coder.
@mikeckennedy8 жыл бұрын
+KC Abramson Thanks so much KC!
@nfskis12 жыл бұрын
It's just Amazing. Very easy to understood what I have to study it!. Thanks you so much Michael. I love your video!! BEST C# Video ever!
@kevinpacheco816910 жыл бұрын
This was amazing, thank you so much for putting this up!
@kirkbae98089 жыл бұрын
I agree. Best explanation on this topic. Thank you very much.
@grog81647 жыл бұрын
Hey, great video! I have a question if I may. At 43:05 we see that we are on the main thread with the while true loop. If I understand correctly, because of async/await keyword on Task.Delay it mean that : "during the 200 ms of delay, the code execution is at exterior of the infinite loop, which makes the program not freezing and then (after 200ms) go back to your loop with your conditionnal SearchStats.downloadCount that is executed within few ms." If I remermber correctly you said that the await in from of something could be seems as a "continue" keyword allowing the code to proceed. But why the code goes exterior ?
@mikeckennedy7 жыл бұрын
Thanks. Basically, the await delay pushes a callback onto the event loop and then releases the UI thread. So while it looks like it should totally freeze up the program but because it does the callback + releases the thread each time through the loop all is well.
@mikeckennedy11 жыл бұрын
Thanks Daniel! You're most welcome. I appreciate the feedback. :)
@DJDoena10 жыл бұрын
Question: at 46:45 you can see that your new method has an await in it. Wouldn't that mean that the calling method with the loop would still be waiting for every download to complete before starting the next?
@mikeckennedy10 жыл бұрын
Hi DJ, There are two loops. The first foreach loops starts ALL the downloads and adds them to a List. At this point they are all running. The while loop just pulls them out as they finish, but they have all been started prior to hitting the while loop with the await. Make sense?
@responsibleparty8 жыл бұрын
Great explanation of these concepts. Of course, the "message pump" version of the multithreading causes some problems that you didn't address. For example, when you click the Search button, it will be possible to click it again while it is running. These are the types of issues I think can be tricky. Clearly, you'd need to prevent that somehow.
@brakes25511 жыл бұрын
Thanks Michael, was cool. This is kind of an odd question..is there anyway for components in the WPF framework to work Asynchronously, such as when displaying a treeView that has many nodes attached to it that it will load the nodes one by one onto the screen instead of the entire mainwindow locking until the treeview has finished processing?
@thebeauti1019 жыл бұрын
Thank you for a great tutorial Michael!
@amaterasu4810 жыл бұрын
This was very informative and easy to understand. Thank you!
@mikeckennedy12 жыл бұрын
Hi, are you asking for visual studio theme or for the powerpoint stuff?
@claudiovalerio725311 жыл бұрын
Great video, great features! For decompiling, I suggest "Just Decompile" by Telerik: free, light and it just does the job!
@mikeckennedy12 жыл бұрын
If we did a Parallel.ForEach, we'd have a thread tied up for each pending request in addition to just the network wait. So we would add some overhead. It wouldn't be computational overhead in this case, but realize that we are then tied to the thread pool which limits the number of threads (approx 20 / CPU in practice) and each one requires 1 MB stack space. So it'd be similar, but we do get some truly new benefits from this Task.WhenAny version. Cheers, @mkennedy
@ncaatrackstar9 жыл бұрын
I loved your tutorial, but why didn't you use the 1st Task example when trying to demonstrate the async and await commands? It would be great to see a 1 to 1 comparison.
@apraveen2512 жыл бұрын
Excellent demo. Thank you very much. Can you check the link for demo code as its not working right now?
@gauravtemkar852410 жыл бұрын
Great Video! Thanks for the cool stuff..! :) Keep up the good work
@K0nc3pt10n7 жыл бұрын
Excellent video! Very well explained.
@klue1611 жыл бұрын
Any plans in the future to continue this tutorial? Maybe covering best practices in a multitude of situations? Dos & don'ts, etc.
@mikeckennedy11 жыл бұрын
No immediate plans directly on this series, but we are adding about 6 hours on this to LearningLine: learninglineapp.com/schedule I can let you know when it's ready.
@klue1611 жыл бұрын
Michael Kennedy , thank you! Definitely signing up. :-)
@TheTrueSmitch8 жыл бұрын
Michael! Wonderful video however I was wondering about a few things. First of all I noticed in your web search example you only used await at the once part. My question for that part was since you only used that would the thread run all the other code besides the await or would it just run it asynchronously but not run other tasks on the same thread.
@ej26497 жыл бұрын
Thank you Michael! Really help! Good tutorial.
@mikeckennedy11 жыл бұрын
Sure, see the description of the video.
@mahensavale8 жыл бұрын
Great explanation Michael !
@mikeckennedy8 жыл бұрын
+Mahendra Savale Thank you!
@NickMaovich11 жыл бұрын
Really nice explanations, examples, and code! Thank you a lot!
@dangnguyenvinhphuoc72067 жыл бұрын
Hi Mchael, this is good video to learn about Async and await, I could I have a example code of the second part (download using async). Thanks,
@mikeckennedy7 жыл бұрын
Thanks. The only code I have still around is at s3.amazonaws.com/michael-kennedy/blog/asynchronous-programming-in-net-4-5-video/websearcher-final-async-await-kennedy-demo.zip Hope that works!
@mikeckennedy12 жыл бұрын
Thank you everyone!
@arpit2803928 жыл бұрын
Thanks a lot Micheal...very clear explanation.
@mikeckennedy8 жыл бұрын
+Arpit Jain You're welcome!
@mikeckennedy12 жыл бұрын
I'd be happy to, however, I'm not sure where it is anymore. :(
@ChinmayGadre11 жыл бұрын
very succinct training on async and await!
@nikitashrivastava88009 жыл бұрын
Great work !!! will keep this forever for reference :)
@mikeckennedy9 жыл бұрын
+Nikita Shrivastava Thank you so much Nikita!
@mikeckennedy11 жыл бұрын
Hi. I didn't do anything special. This is just the theme of Win8 at the time - was running a dev preview of win 8.
@weima5447 жыл бұрын
Explained so clearly, thanks
@klue1611 жыл бұрын
Awesome tutorial!! Thank you so much; really helpful.
@mikeckennedy11 жыл бұрын
Thanks, glad you like it!
@mikeckennedy12 жыл бұрын
Thanks Omar. I updated the link in the comments for downloading the code.
@karenwoods85679 жыл бұрын
Hi Mike, where do we download the source code used in this tutorial? Please advise. Thanks..great video btw
@lynndemarest19026 жыл бұрын
One word: Brilliant. Thank you. (OK three words.)
@mikeckennedy6 жыл бұрын
Thanks a bunch Lynn. Glad it was helpful. :)
@mikeckennedy11 жыл бұрын
Glad you liked it. Great analogy!
@rmzzz768 жыл бұрын
Thank you so much for the information.... While I think the Task functionality added with .NET 4.0 is intuitive and useful, the sync / await syntax and overall paradigm were a poor direction. C# has not aged very well.
@krishnakantsharma0910 жыл бұрын
Very nicely explained. Thanks :)
@a1689k11 жыл бұрын
The code doesnt work.. The search always returns an empty list, no matter whatever you search, and how much ever you increase the "entire internet".. could be a minor bug in the parallel programming logic.. as I am new to it, cannot fix it.. can anyone help?
@mikeckennedy11 жыл бұрын
Hi. I just downloaded the code, recompiled it and ran it. Works fine. Try a common term like truck or something.
@varshacon11 жыл бұрын
Hi Michael, could you please paste the link again, I don't find the link anywhere. Thanks.
@ahmxtb11 жыл бұрын
Why 48:00 using .ToArray()? I think it's not needed.
@mikeckennedy12 жыл бұрын
You're welcome, thanks for saying so.
@mikeckennedy12 жыл бұрын
Check the source, just updated the download like to work.
@nileshdDeolikar4 жыл бұрын
I want to DataGrid.DataSource = dbcontext.selectcateroties(0, 1).ToList(); in task
@JoshYates10 жыл бұрын
Well explained. Thank you sir.
@mikeckennedy10 жыл бұрын
Thanks!
@kllbd4 жыл бұрын
hey dude, what's this Windows version? :o I was looking for it, but I didn't find the right version.
@PythonBytes4 жыл бұрын
Hi. I think that sweet OS is Vista. :) It wasn't that great but was OK. Looked good.
@vkg.codefactory10 жыл бұрын
Nice presentation, where can I find the demo source code?
@vkg.codefactory10 жыл бұрын
I got it, it is just mentioned in the bottom notes, sorry!
@JoshYates10 жыл бұрын
Vinod Kumar Gupta The link was broke. hmmm....unless it's a firewall issue.
@jayeshmodha11 жыл бұрын
Thank you sir, you have a great teaching skill
@IWIH909 жыл бұрын
Thank you for the awesome tut.
@ranjithk8426 жыл бұрын
Nicely explained!!! Thanks
@garyngzb12 жыл бұрын
what theme you use?
@varshacon11 жыл бұрын
Link to source code for both projects please.
@ReductioAdAbsurdum12 жыл бұрын
This is an interesting talk, but the motivation presented at the start is not relevant (free lunch is over). The `async` keyword doesn't make it any easier to parallelize computation for purposes of increasing CPU utilization on a multi-core machine. It mostly makes it easier to write code that waits on long processes without blocking out main thread, for purposes of app responsiveness.
@PaulSebastianM11 жыл бұрын
Windows 8 with non-standard theme? How?
@ryanjackson0x12 жыл бұрын
Can you share your slidedeck?
@NGUY003510 жыл бұрын
awesome explaination!
@mikeckennedy12 жыл бұрын
Thanks Lucas! Much appreciated.
@mikeckennedy12 жыл бұрын
Thanks Cuong!
@Yartch12 жыл бұрын
Thanks, great video! This really cleared a lot up for me.
@ThugLifeModafocah4 жыл бұрын
The Async vs Parallel (1) is real parallelism. Two or more processing cores taking tasks in parallel. The Async vs Parallel (2) is concurrency. There's no real parallelism, the tasks are processed one at a time, switching very fast, giving the impression of simultaneos processing, but it's not. So async can be either parallel or concurrent and it is a big improviment from serial processing.
@menakaramasamy893611 жыл бұрын
This is amazing video. Thanks a lot.
@loam5 жыл бұрын
5:40 - dude foresaw the future, AMD Threadrippers and others really did came out.
@mikeckennedy5 жыл бұрын
:)
@iElite680910 жыл бұрын
Great video. You just earned yourself a like and a subscription from me!
@prosoftwebindia9 жыл бұрын
Nice! Thank You.
@jmng968912 жыл бұрын
Great work.
@somnath.sonawne11 жыл бұрын
Excellent video !!!!!!!!
@ZackLoveless12 жыл бұрын
Great video, thanks!
@mikeckennedy12 жыл бұрын
Thanks Joe!
@pr0l0gix7 жыл бұрын
awesome!! thanks!!
@milanmladenovic12 жыл бұрын
Great video! Thanks
@voodark11 жыл бұрын
Thank you very much!!
@mikeckennedy12 жыл бұрын
Thanks, link updated!
@cuongdev12 жыл бұрын
the video's so good, thanks.
@swoyum12 жыл бұрын
Informative !
@KavkkAZEcc8 жыл бұрын
Thanks for tutorial
@ipekb30399 жыл бұрын
Thank you sir.
@davidfreire37669 жыл бұрын
good work ;)
@mikeckennedy12 жыл бұрын
Thanks!
@dannyc.869610 жыл бұрын
bill gates disliked this video at 29:48
@evyngreenwood61088 жыл бұрын
Nah, like always, the only time apple is more useful than windows is when the windows user fucks up.
@sujithpattambi7 жыл бұрын
No, he will not :) . It is typo "suface" instead of "surface"