C# Async / Await - Make your app more responsive and faster with asynchronous programming

2024 ж. 19 Мам.
982 118 Рет қаралды

Asynchronous programming can be intimidating. What is even worse is when you think you learned how to do something and then you try it in your application, and it doesn't work. This video is an attempt to fix all of that. In it, you will see how to use the async and await keywords to make your user interface more responsive and to speed up your code's operation. You will also see how to turn an existing method from being synchronous to asynchronous. Along the way, we will cover best practices and how to make sure our application behaves like we expect after we make a part of it asynchronous.
Mailing List: signup.iamtimcorey.com/
Source Code: leadmagnets.app/?Resource=Asy...
0:00 - Intro
2:23 - Demo application walk-through
4:33 - Code behind the demo application: Synchronous operation
10:36 - Creating Async Task
22:39 - Creating Parallel Async
30:51 - Recap
33:00 - Wrapping method in Task.Run() vs Async method call
35:42 - Summary

Пікірлер
  • Mr. Tim, One of the advantages of C# is that you teach it.

    @FunnySubmarine-ij4zk@FunnySubmarine-ij4zkАй бұрын
    • I appreciate the kind words.

      @IAmTimCorey@IAmTimCoreyАй бұрын
  • Tim, Thanks. This is the only "usable" explanation I found about async programming.

    @dirkvaneester2946@dirkvaneester29464 жыл бұрын
    • I am glad it was helpful.

      @IAmTimCorey@IAmTimCorey4 жыл бұрын
    • sorry to be off topic but does any of you know of a method to log back into an Instagram account?? I was stupid lost my login password. I would appreciate any tips you can offer me!

      @camdynvalentin9051@camdynvalentin90512 жыл бұрын
    • @Pedro James thanks so much for your reply. I found the site thru google and I'm in the hacking process atm. Seems to take a while so I will reply here later when my account password hopefully is recovered.

      @camdynvalentin9051@camdynvalentin90512 жыл бұрын
    • @Pedro James it worked and I actually got access to my account again. I'm so happy:D Thank you so much you really help me out !

      @camdynvalentin9051@camdynvalentin90512 жыл бұрын
    • @Camdyn Valentin happy to help :D

      @pedrojames6149@pedrojames61492 жыл бұрын
  • I am senior .NET developer and I still use your tutorials and love watching you. One can never know enough. You are really awesome teacher and this tutorial on async/await is just what I needed. I know it is something what we are supposed to use, but not really have any real knowledge on WHY exactly. So awesome, especially with parallel.

    @zoran123456@zoran1234564 жыл бұрын
    • Awesome! I am glad my videos are still helpful.

      @IAmTimCorey@IAmTimCorey4 жыл бұрын
    • One can, but probably two can't

      @b213videoz@b213videoz2 жыл бұрын
  • Just another student passing by to say thank you! Your slow and steady learning method is so much better than "Become a C# master in 5 minutes" type of videos

    @TheMedicinMannen@TheMedicinMannen3 жыл бұрын
    • You're very welcome!

      @IAmTimCorey@IAmTimCorey3 жыл бұрын
  • The best one that I've seen. Impressed how you can explain such a complicated concept in such a simple way!

    @jeffwang1715@jeffwang17152 жыл бұрын
  • Found your channel like a week ago, and I've been watching at least one video every day, and I'm learning a lot. Thank you Tim Corey, and you do make learning coding easier

    @thesophisticatedvelocirapt7320@thesophisticatedvelocirapt73203 жыл бұрын
    • Great to hear!

      @IAmTimCorey@IAmTimCorey3 жыл бұрын
  • I'm a sr dev, and enjoy watching tech videos now and then, especially in the background as noise while working. I always enjoy your videos, recently discovered, as they provide different perspectives in how things are done or explained. I find explaining technical things like this to non technical persons a challenge, but you keep it simple, my motto, and that helps me to communicate with non technical peeps...

    @EnergizerTX@EnergizerTXАй бұрын
    • I'm glad you find them valuable.

      @IAmTimCorey@IAmTimCoreyАй бұрын
  • Thank you Tim. I've been looking for video tutorials like this for a LONG time now. Your C# video tutorials are taught so nicely and you make it easy to understand. Most programming tutorials are either too fast or slow. Most videos have terrible audio but yours is beautiful. You are so helpful, please don't stop making videos.

    @EvanDear@EvanDear5 жыл бұрын
    • I appreciate the kind words.

      @IAmTimCorey@IAmTimCorey5 жыл бұрын
  • It is amazing how you wrestle complicated subjects to their knees with such a smooth narration that is so easy to follow and understand. Thank you!

    @briank.daniels7939@briank.daniels79393 жыл бұрын
    • I appreciate that!

      @IAmTimCorey@IAmTimCorey3 жыл бұрын
  • Even after one year, and this is still my best explanation of async/await in C#. Thank you, Tim.

    @0lay3mi@0lay3mi4 жыл бұрын
    • You are welcome.

      @IAmTimCorey@IAmTimCorey4 жыл бұрын
  • Great work Tim, I like the way you overview the basics first then come back & drill down. You are a gifted teacher.

    @shaynemurray6351@shaynemurray63516 жыл бұрын
    • I appreciate the kind words.

      @IAmTimCorey@IAmTimCorey6 жыл бұрын
  • Thank you Tim, cristal clear! Whenever I have a question during my course, I'll just search your channel, watch a video and BAM, question solved! Much appreciated!

    @louisbroucke2990@louisbroucke29903 жыл бұрын
    • I am glad my content is so helpful.

      @IAmTimCorey@IAmTimCorey3 жыл бұрын
  • Been diving in C# lately and I just couldn't get async/await/Tasks to click until watching this. Thank you for breaking each piece down and making them less intimidating to use

    @claya1532@claya15322 жыл бұрын
    • You are welcome.

      @IAmTimCorey@IAmTimCorey2 жыл бұрын
  • The best and clearest explanation of async/await I have ever seen. Look forward to watching some of your other videos.

    @Ricks_Shorts@Ricks_Shorts4 жыл бұрын
    • Awesome, thank you!

      @IAmTimCorey@IAmTimCorey4 жыл бұрын
    • i agree 200%! Well done!

      @shadowzinny@shadowzinny4 жыл бұрын
  • The relaxed, composed way of explaining this is absolutely sublime - I found the example code for delegates to be very complex; but here it was a treat. You also managed to handle all possible errors I already encountered before that other youtubers seemed to treat as evident. Kudos to you!

    @esdenaze@esdenaze3 жыл бұрын
    • I am glad it was so helpful.

      @IAmTimCorey@IAmTimCorey3 жыл бұрын
  • I just found your channel when looking for blazor information. It was a great experience. Most all other tutorials tell you click here, do this, then this, but never tell you why. You tell me why certain things are done, which is great, it’s how I learn best. During the blazor tutorial, you used async, tasks and await. I wanted to know more and found this tutorial, it explains it perfectly for me and easy to wrap my head around. Thanks. I’ll be watching more of your tutorials as I have time.

    @ronaldolds1034@ronaldolds10343 жыл бұрын
    • Thanks for the nice comments. I strive to educate, not just show examples. It does seem to be helping a lot of folks.

      @IAmTimCorey@IAmTimCorey3 жыл бұрын
    • @@IAmTimCorey Do you have a video of setting up to allow login and restricting access to pages once you are logged on? This would also be in Blazor

      @ronaldolds1034@ronaldolds10343 жыл бұрын
  • Hey Tim - I know this is an old post, but still relevant and useful today. Well done! Perfectly succinct and easy to understand. I've been looking for supplemental teachings for our new team members that won't take a week to consume, and it was a blessing to stumble across your channel. Thank you for sharing and make it a Merry Christmas!

    @MichaelHortonNow@MichaelHortonNow2 жыл бұрын
    • Glad it was helpful!

      @IAmTimCorey@IAmTimCorey2 жыл бұрын
  • Best video on tasks I've seen so far. Not confusing in the slightest anymore.

    @jeffg4686@jeffg46865 жыл бұрын
    • Excellent!

      @IAmTimCorey@IAmTimCorey5 жыл бұрын
  • Fantastic class. I've been studying this subject for a long time, but never found so clean and straightforward explanation. Congrats!!!

    @eltoncastrosousa@eltoncastrosousa5 жыл бұрын
    • Thank you!

      @IAmTimCorey@IAmTimCorey5 жыл бұрын
  • I have watched this tutorial about 10 times now and I get more and more understanding each time as I implement async in my apps where some methods I have control over and some I don't. This is seriously a huge help! Thank you so much for making this!

    @godfathermikal@godfathermikal5 жыл бұрын
    • Awesome! I'm glad it has been so helpful.

      @IAmTimCorey@IAmTimCorey5 жыл бұрын
  • Hi Tim,I am in love with your teaching. The way you teach it becomes very easy to understand. Thanks for all your effort you put in to help us.

    @truptibaliarsingh5441@truptibaliarsingh54412 жыл бұрын
    • You are welcome.

      @IAmTimCorey@IAmTimCorey2 жыл бұрын
  • Wow, that was incredible. I had just learnt the syntax of the keywords but didn't understand what they do and how they'd be useful. This video showed me exactly what I was looking for. Thank you so much .

    @muratkabak6212@muratkabak62123 жыл бұрын
    • Tim's goal is true education. As you point out, that is more than just memorization of syntax and keywords. We are glad you found the video helpful!

      @tomthelestaff-iamtimcorey7597@tomthelestaff-iamtimcorey75973 жыл бұрын
  • Tim, I can't say this enough. You are the best ever! You're videos are on a level of their own. No courses or videos I have seen explain stuff as good as you! Thank you for everything!

    @mohamedmotaz1116@mohamedmotaz11163 жыл бұрын
    • Wow, thanks! I appreciate that.

      @IAmTimCorey@IAmTimCorey3 жыл бұрын
  • Loved this! This was my first Tim Corey video, but I have to say he is the best presenter I've seen on the topic. He takes it easy, explains thoroughly, and somehow managed to explain EXACTLY the issues I had on mind after seeing other videos and reading some material. Many thanks!

    @raskand1977@raskand19776 жыл бұрын
    • Awesome! I am glad you found it so valuable.

      @IAmTimCorey@IAmTimCorey6 жыл бұрын
  • Before I watched this, based on everything else I had watched, I just though Async methods always had to be followed with Await keywords next to the sub tasks within the methods even though they were completely unrelated sub tasks. And I wondered why my apps still ran "synchronously"! This is such a good video introducing one to asynchronous programming the right way! Thank you for taking the time to put this together! Now over to your advanced async video!

    @leonsoares7405@leonsoares74054 жыл бұрын
    • You are most welcome. Thanks for watching.

      @IAmTimCorey@IAmTimCorey4 жыл бұрын
  • THANK YOU Tim! This is such a clear explanation on Asynchronous. It blew me away! To think I've been programming most of my life linearly (except for a few multi-threading things I've done). I am a new fan of your series!

    @hectorhenry9841@hectorhenry98414 жыл бұрын
    • You are most welcome. Thanks for watching.

      @IAmTimCorey@IAmTimCorey4 жыл бұрын
  • OMG been working at this on and off for so long and not figuring out what I was doing right/wrong. Thank you so so so much!!!! I completely understand now and see a productive week at work coming my way. Best tutorial ever!

    @nathanielriehl623@nathanielriehl6235 жыл бұрын
    • Awesome! I'm glad it finally clicked.

      @IAmTimCorey@IAmTimCorey5 жыл бұрын
  • The best informative channel I've ever seen about programming... Thanks a lot sir!

    @devvorpian7255@devvorpian725510 ай бұрын
    • You are welcome.

      @IAmTimCorey@IAmTimCorey10 ай бұрын
  • DUDE! Thank you so much!! This was my third attempt trying get a working understanding of Async/Await and this did the trick! You are a baller!

    @josephpatchen3421@josephpatchen34212 жыл бұрын
    • Awesome!

      @IAmTimCorey@IAmTimCorey2 жыл бұрын
  • I've been using these statements for 2 years now, and you just expanded my knowledge. Man, when I hit a demo where they start by creating a project I move on. Thanks for making every minute so full.

    @HarveyMyers@HarveyMyers2 жыл бұрын
    • You are most welcome. Thanks for watching.

      @IAmTimCorey@IAmTimCorey2 жыл бұрын
  • I was stuck on how to synchronise my tasks executions. Thank you! After watching this video, all starts to make sense. Thank you very much for your step-by-step and concise explanations.

    @weizhen77@weizhen775 жыл бұрын
    • You are most welcome. Thanks for watching.

      @IAmTimCorey@IAmTimCorey5 жыл бұрын
  • As someone who have learned async as "This is how you do async in the code. Don't ask why just do it" I never really understood why. I understood that the program could run asynchronous but never really grasped why or rather how it ran asynchronous. After the 25 minute mark I got the Ooooh now I get it. Thank you so much.

    @CodeZeeZ@CodeZeeZ3 жыл бұрын
    • Thanks for watching and trusting Tim to be a part of your coding journey.

      @tomthelestaff-iamtimcorey7597@tomthelestaff-iamtimcorey75973 жыл бұрын
    • same here. I have a solution full of external api calls database access, and they all "run asynchronously". I followed tutorials and troubleshot some caveats, but never really understood how to tackle async calls to make it actually efficient. Guess I have a lot of code to review now :)

      @sparking023@sparking0233 жыл бұрын
  • Excellent video. I'm doing a course where we are shown how to make a web server and next task was to make it run async. I did that following the provided tutorial but that didn't help understand what is going on exactly. Plus it's always better to see it explained in a simple app like what you did. Thank you for this tutorial. For me 30 minutes is considered a short tutorial. 10-15 would be too short to understand and this was perfect and straight to the point. You explained everything in a couple of different ways and never strayed away from the topic at hand. It's rare to see such well structured tutorials. I will be back for more! (this reminded me of an old game called Chessmaster, you explain things in a similar fashion to the Grandmaster (Joshua Waitzkin) who did the tutorials in that game)

    @ted88@ted885 жыл бұрын
    • Excellent! I'm glad it was so helpful to you.

      @IAmTimCorey@IAmTimCorey5 жыл бұрын
  • I watched a few videos on this topic and for the first time I understand this concept. I like that you explain in details so newbies like me can wrap our heads around it. Keep up the great work!!

    @davidyue6310@davidyue63105 жыл бұрын
    • Thanks, will do!

      @IAmTimCorey@IAmTimCorey5 жыл бұрын
  • This video cleared up so many misconceptions I had around async methods and how to use them. Fantastic!!! Keep doing what you are doing because it is working!

    @tomc2534@tomc25344 жыл бұрын
    • Thank you!

      @IAmTimCorey@IAmTimCorey4 жыл бұрын
  • Thank you Tim. I was desperately looking for enlightenment of async on C#

    @kalvinwei19@kalvinwei193 жыл бұрын
    • Glad it was helpful!

      @IAmTimCorey@IAmTimCorey3 жыл бұрын
  • Straight to the point and easy to understand. You've got yourself another sub. Thank you for your time and effort put into this! :)

    @napstericious@napstericious Жыл бұрын
    • Thanks!

      @IAmTimCorey@IAmTimCorey Жыл бұрын
  • This is in my head the video that helped me the most out of all I have seen on youtube. Learning asynchronous programming is well worth the time to learn and really makes things feel more streamlined and snappy. Also you gain control of when your tasks start and stop in a easy way.

    @northernpanda6953@northernpanda69533 жыл бұрын
    • I am glad you enjoyed it.

      @IAmTimCorey@IAmTimCorey3 жыл бұрын
  • I’ve now watched a two digit number of videos covering this topic because I wanted to calculate the async way. Thanks to you my journey is finally over. Fantastic video!

    @Octavius145@Octavius1452 жыл бұрын
    • Glad it was helpful!

      @IAmTimCorey@IAmTimCorey2 жыл бұрын
  • Dude, you're wicked. I always expect a video from that Indian guy but then you come through.

    @MindBodyMeditate@MindBodyMeditate4 жыл бұрын
    • I'm assuming that's a good thing. :-)

      @IAmTimCorey@IAmTimCorey4 жыл бұрын
  • Absolutly great tutorial. Finally I understood the async procedure. Thanks a lot !

    @KleineDrehmomente@KleineDrehmomente2 жыл бұрын
    • You are welcome.

      @IAmTimCorey@IAmTimCorey2 жыл бұрын
  • Probably one of the best tutorials for async out there, if not the best. Really good job!

    @jaimecanoramos5207@jaimecanoramos52072 жыл бұрын
    • Thank you!

      @IAmTimCorey@IAmTimCorey2 жыл бұрын
  • Really cool that you showed how to run things in parrallell as well and explained the difference. Best video I have seen on async!

    @soucianceeqdamrashti8175@soucianceeqdamrashti81754 жыл бұрын
    • Thank you!

      @IAmTimCorey@IAmTimCorey4 жыл бұрын
  • The best asynchronous programming video on KZhead!!

    @longuinni@longuinni6 жыл бұрын
    • Wow, thanks!

      @IAmTimCorey@IAmTimCorey6 жыл бұрын
  • Excellent video. I'm fairly new to C# and found this video to be to the point, very easy to follow and the code to be highly readable. I learned a lot!

    @MrLilleblomst@MrLilleblomst4 жыл бұрын
    • Great!

      @IAmTimCorey@IAmTimCorey4 жыл бұрын
  • Lifesaver! So many of the exampes for using Async were not directed at simply running your own functions on the side, you explained this very clearly and allowing me to add custom async pathfinding to my AI. Thanks!

    @LostConjugate@LostConjugate6 жыл бұрын
    • Excellent! I'm glad you were able to apply it right away.

      @IAmTimCorey@IAmTimCorey6 жыл бұрын
  • Thank you Mr. Corey. That was absolutely the best explanation I've heard concerning asynchronous programming. I have enjoyed your videos very much. Once again, "thank you".

    @charlesdodson829@charlesdodson8295 жыл бұрын
    • Awesome! I'm glad it was clear and enjoyable.

      @IAmTimCorey@IAmTimCorey5 жыл бұрын
  • The best explanation of Async Await by far without a lot of fuss and confusing terms!!!

    @gauravparvat5291@gauravparvat52916 жыл бұрын
    • Thanks!

      @IAmTimCorey@IAmTimCorey6 жыл бұрын
  • Hi Tim, I am still quite new to learning C# specifically. I see there are some haters, but don't mind them. I appreciate your videos for not having a strange or annoying accent and also appreciate the real life implementations and examples as well as access to the source code. I appreciate that you take the time to explain things in detail and calling them on their correct name (eg. lambda expression). I also do not feel that you rush sentences or have trouble with articulation. Opinions are like a-holes, everybody has one. And that is just the opinion of some a-hole. Your content is superb and I hope to soon be able to contribute and take some of your paying courses. Thanks for your hard work, which makes my life easier.

    @dewaldgroenewald5711@dewaldgroenewald57114 жыл бұрын
    • I appreciate the kind words.

      @IAmTimCorey@IAmTimCorey4 жыл бұрын
  • Best explanation about Async / Await I've ever seen! Thank you.

    @henriquejvalho@henriquejvalho6 жыл бұрын
    • Awesome!

      @IAmTimCorey@IAmTimCorey6 жыл бұрын
  • I've come across your videos before; But when watching this video, I was able to better appreciate your lecturing skills, since this is one of the more complex topics in programming. Thank you Tim!

    @efezaladin3236@efezaladin32364 жыл бұрын
    • You are welcome.

      @IAmTimCorey@IAmTimCorey4 жыл бұрын
  • 0:00 - Intro 2:23 - Demo application walk through 4:33 - Code behind the demo application: Synchronous operation 10:36 - Creating Async Task 22:39 - Creating Parallel Async 30:51 - Recap 33:00 - Wrapping method in Task.Run() vs Async methhod call 35:42 - Summary

    @RalfsBalodis@RalfsBalodis3 жыл бұрын
    • Thanks! I added it to the description.

      @IAmTimCorey@IAmTimCorey3 жыл бұрын
  • Wow, this is pretty much like async/await and Promise in JS. The video was really easy to understand with that in mind.

    @alexzinkevych3596@alexzinkevych35964 жыл бұрын
    • Great!

      @IAmTimCorey@IAmTimCorey4 жыл бұрын
  • God bless you. You have cured my confusion of async, await, and running tasks in parallel all in one go. I tried going everywhere: chatgpt, stackoverflow, google, and none of them answered all of my questions - ok except getting to you from google... You answered all of my questions and then some. Keep up the good work. Bookmarking this and going back to this video again and again.

    @engineerchaos8424@engineerchaos8424 Жыл бұрын
    • I am glad it was helpful.

      @IAmTimCorey@IAmTimCorey Жыл бұрын
  • Really enjoyed the clear and concise explanation. I've seen asynchronous code many times but this really made things crystal clear

    @danielsauter5326@danielsauter53264 жыл бұрын
    • I'm glad you enjoyed it.

      @IAmTimCorey@IAmTimCorey4 жыл бұрын
  • Much more clear than all of the examples I’ve seen floating around. Finally think I can put this to use!

    @Classicv5@Classicv55 жыл бұрын
    • Great!

      @IAmTimCorey@IAmTimCorey5 жыл бұрын
  • I know this is unrelated but thank you for bringing that trick with the $ symbol with a string to my attention! That's seriously useful, since now I can clean up my code a little, get rid of all this "some string: " + someValue + ", some other string: " + someOtherValue crap. Also very nice explanation! I've yet to delve into asynchronous programming but I envisage this being extremely useful in my current project :)

    @logix8969@logix89694 жыл бұрын
    • I am glad you got some value out of the video.

      @IAmTimCorey@IAmTimCorey4 жыл бұрын
  • I'm wondering... Why do i find this video only now??? Thank you so much. It was so easy to understand it with you

    @thebigmoon8372@thebigmoon8372 Жыл бұрын
    • I am glad you found it.

      @IAmTimCorey@IAmTimCorey Жыл бұрын
  • Hi Tim, You're an amazing teacher, and I enjoy your tutorials very much. Thanks a lot and keep up the good work!

    @yairashkenazi5455@yairashkenazi54554 жыл бұрын
    • You are welcome.

      @IAmTimCorey@IAmTimCorey4 жыл бұрын
  • First time I watch one of your videos and I think it you have one of the best channels with programming content. It is very helpful.

    @qapolo9196@qapolo91964 жыл бұрын
    • Thank you!

      @IAmTimCorey@IAmTimCorey4 жыл бұрын
  • You are brilliant in teaching sir 🙏🏼

    @advaitharmy@advaitharmy3 жыл бұрын
    • So nice of you

      @IAmTimCorey@IAmTimCorey3 жыл бұрын
  • Great explanation and demo!

    @KarChunChua@KarChunChua2 жыл бұрын
    • Thank you!

      @IAmTimCorey@IAmTimCorey2 жыл бұрын
  • This is the best video tutorial on "async / await" I have ever seen!!! thank you so much Tim

    @razzer57@razzer572 жыл бұрын
    • You are welcome.

      @IAmTimCorey@IAmTimCorey2 жыл бұрын
  • THANK YOU SO MUCH!!! Spent the whole night looking for this, just wanted a simple way of loading some internet data without blocking the UI and everything I found online was either not appropriate or way too complicated, thank you so much for the simple and clear explanation!

    @RaquelSofiaUni@RaquelSofiaUni2 жыл бұрын
    • I am glad it was so helpful.

      @IAmTimCorey@IAmTimCorey2 жыл бұрын
  • Best channel to learn c#. Wish I known it earlier

    @atnguyen5442@atnguyen54424 жыл бұрын
    • Thank you!

      @IAmTimCorey@IAmTimCorey4 жыл бұрын
  • Best video on async await.

    @kartikk7402@kartikk74025 жыл бұрын
    • Thank you!

      @IAmTimCorey@IAmTimCorey5 жыл бұрын
  • This subject it's a little bit overwhelming when you're not used to it. This video helps a lot explaining the entire process of implementing asynchonous features, while most of the other similar videos just shows parts of the process. Everything in a good pace to learn without rush. This content is even more valuable as the time passes, given that REST API integration higly benefits on asynchonous requests and it's something that we developers do more and more on a daily basis. Probably the best explanation of asynchronous concepts I ever seen. Please keep doing this marvelous work. Thanks!

    @marcomvidal@marcomvidal5 жыл бұрын
    • Awesome! I'm glad it was so helpful.

      @IAmTimCorey@IAmTimCorey5 жыл бұрын
  • Your voice and English accent are good. Few of vedios that not hurt my ears!Thanks!

    @FranChen1984@FranChen19845 ай бұрын
    • You are welcome.

      @IAmTimCorey@IAmTimCorey5 ай бұрын
    • Also few comments that don't hurt my eyes 😁

      @LaurentChabenet@LaurentChabenet5 ай бұрын
    • Yeah great 🎤. By the way what model mic are you using I want to start making some tutorials

      @trustingod0@trustingod04 ай бұрын
  • This is so incredibly helpful. I absolutely love your teaching style. Thank you for this. If you don't already do Udemy courses, I think you should.

    @KyleWestendorf@KyleWestendorf6 жыл бұрын
    • Thanks! I don't teach Udemy courses (for a number of reasons, mostly around control) but I do sell courses on my website ( IAmTimCorey.com ). If you join my mailing list, you will also hear about the new courses that are coming out and get exclusive discounts on said courses.

      @IAmTimCorey@IAmTimCorey6 жыл бұрын
  • Sir, you're the best. I've watched like 5-6 videos about that but couldn't understand when we have to use await when not etc. But all of them clear now. Thank you for teaching! ❤

    @lastidea4925@lastidea49252 жыл бұрын
    • Awesome! I’m glad it clicked.

      @IAmTimCorey@IAmTimCorey2 жыл бұрын
  • You and your videos are fantastic. Learning async using the offical documentation felt kind of daunting and convoluted. You made it clear!

    @david3552@david35522 жыл бұрын
    • I appreciate the kind words.

      @IAmTimCorey@IAmTimCorey2 жыл бұрын
  • Six months of frustration, 25 mins of tim corey (sorry I watch at 1.5x :D ...) to solve it.

    @mekkanikmike@mekkanikmike2 жыл бұрын
    • I am glad it was so helpful.

      @IAmTimCorey@IAmTimCorey2 жыл бұрын
  • Great explanation, what i found interesting from what it appeared to me the order of the results came back in the same order for the Sync and Async. Just a bit strange but i really doubt you're doing anything weird, sure you'd agree order shouldn't be deterministic but just happened this way by random chance. But this was great explanation and above all don't want my comment to take away from how good the video is, just an observation, guess that's why i'm a tester at heart :)

    @dand4485@dand44854 жыл бұрын
    • Do you mean in the 'parallel' method? The tasks could have finished in any order. But the result array will contain the results in the same order as the Task[]. (So, tasks[0].Result will be in results[0], tasks[1].Result in results[1], etc) That's why the foreach loop will always enumerate them in the same order.

      @dennisekkelenkamp2303@dennisekkelenkamp23034 жыл бұрын
    • @@dennisekkelenkamp2303 Ah perfect, i see my mistake, thanks for your kind response, thiink i see my mistake. The list will contain the items in order as how you added them... (duh, shouldn't watch these at 1am when i'm not thinking straight...) Think my erroneous thinking is a hold over to the old ways of treaing i.e. a thread pool and worker threads, that's me, wanting to over complicate it :) And that might be true under the covers in the state machine which .Net/C# is providing but we only have the reference to the object in the list Task, an they will be in "insertion order". Thank for the clarification perfectly clear now :) Have a GREAT DAY!

      @dand4485@dand44854 жыл бұрын
    • Nice job both of you. I'm glad to see you both contributing positively to the community. Thanks for watching.

      @IAmTimCorey@IAmTimCorey4 жыл бұрын
  • Awesome overview with great, simple examples. I definitely learned the async/await pattern best through your lesson. Rock on! 🤘

    @stevieray8450@stevieray84505 жыл бұрын
    • Awesome!

      @IAmTimCorey@IAmTimCorey5 жыл бұрын
  • Thanks!

    @codefoxtrot@codefoxtrot Жыл бұрын
    • Thank you!

      @IAmTimCorey@IAmTimCorey Жыл бұрын
  • Wow! This is simply the best Async tutorial! I managed to completely understand it despite being a complete beginner! Thank you very much for providing such amazing stuff for free.

    @Chapali9a@Chapali9a3 жыл бұрын
    • You're very welcome!

      @IAmTimCorey@IAmTimCorey3 жыл бұрын
  • Thank you Tim! This helped alot. I used this as a reference with my project that makes use of a database and a class library as a dependency to my UI project and is now 100% responsive.

    @kiaanmaharaj@kiaanmaharaj2 жыл бұрын
    • Awesome!

      @IAmTimCorey@IAmTimCorey2 жыл бұрын
  • Wichtig und richtig.

    @timkaiser3820@timkaiser38202 жыл бұрын
    • Thanks!

      @IAmTimCorey@IAmTimCorey2 жыл бұрын
  • Great video, you explain things very well. I think, however, your parallel method isn't actually running parallel rather its running concurrently.

    @chadiusmaximus9350@chadiusmaximus93502 жыл бұрын
    • That is up to the system. It determines whether to run them concurrently or in parallel based upon how expensive it is to spin up a new thread vs how long it will take waiting on an existing resource.

      @IAmTimCorey@IAmTimCorey2 жыл бұрын
    • @@IAmTimCorey ahh ok, I'm coming from Go where you have to write your code either concurrent or parallel. So you're saying the the .Net runtime handles that automatically? Rob Pike gives a really good talk on the subject.

      @chadiusmaximus9350@chadiusmaximus93502 жыл бұрын
  • I recently started following your courses!! Such a wonderful coaching.. thanks for your time and videos... Love you teaching from India.

    @mcopy9p350@mcopy9p3503 жыл бұрын
    • Awesome! I am glad you are enjoying my videos.

      @IAmTimCorey@IAmTimCorey3 жыл бұрын
  • A great, simple explanation of the fundamentals of a complex topic. Thanks!

    @christopherkreitlow1178@christopherkreitlow11785 жыл бұрын
    • You are welcome.

      @IAmTimCorey@IAmTimCorey5 жыл бұрын
  • Hi Tim Corey ! Thanks for this video Pleace !!! Can you make lessons about 'clean architecture with rest epi in .net 5' Step by step with Audentification and user admin roles ?

    @otkirbeksobirjonov9695@otkirbeksobirjonov96952 жыл бұрын
    • Thanks for the suggestion. While it isn't specifically "clean architecture" design, have you seen the TimCo series? In there, I set up a REST API in .NET 5 that uses Microsoft Identity (using Entity Framework) for authentication and authorization. Then I consume that API in both WPF and Blazor WebAssembly and make use of multiple custom roles.

      @IAmTimCorey@IAmTimCorey2 жыл бұрын
  • Hey Tim, Thanks for the insightful video. A question here, could you explain a bit more on why returning void in an async method (except in an event) is considered a bad practice?

    @sashithafonseka@sashithafonseka Жыл бұрын
    • Because the method cannot communicate a failure to you.

      @IAmTimCorey@IAmTimCorey Жыл бұрын
    • To expand on what Tim said, if it's void, you don't have the Task object, which can contain any exceptions that might have occurred while awaiting the task.

      @jonathanharmon3472@jonathanharmon3472 Жыл бұрын
    • @@jonathanharmon3472 and @IAmTimCorey thank you for the clarification!

      @sashithafonseka@sashithafonseka Жыл бұрын
  • Awesome video Tim. As always, your educational skills are top notch!

    @klasidarlang-larsen1907@klasidarlang-larsen19075 жыл бұрын
    • Thank you for the kind words.

      @IAmTimCorey@IAmTimCorey5 жыл бұрын
  • This is faaaar the best video I've seen about this topic. Thank you so much Tim!

    @eduhza@eduhza5 жыл бұрын
    • You are most welcome. Thanks for watching.

      @IAmTimCorey@IAmTimCorey5 жыл бұрын
  • This video about Async was legen... wait for it ...daryAsync!

    @adiac42@adiac42 Жыл бұрын
    • lol

      @IAmTimCorey@IAmTimCorey Жыл бұрын
    • One could say, await it

      @CrashCubeZeroOne@CrashCubeZeroOne Жыл бұрын
  • Hmm... how would i go about adding a try/catch in the async function? Some of the listed websites sometimes send back an error - i added a try catch block to simply print "protocol error" in these cases, but in the async function that ends up crashing the program with "The calling thread cannot access this object because a different thread owns it." I assume that happens because my try/catch is in the WebsiteDataModel which isn't async itself? Cheers!

    @wildKawa@wildKawa Жыл бұрын
    • This is how I solved this: - Add property 'public string WebsiteStatus { get; set; } = "Ok";' to class 'WebsiteDataModel'. - When calling 'client.DownloadString/DownloadStringTaskAsync' 'catch' the 'WebException' and save 'webException.Status' (and maybe 'webException.Message') in 'output.WebsiteStatus' - Add 'data.WebsiteStatus' to the 'resultsWindow.Text' string in 'ReportWebsiteInfo()' to display it.

      @siggimund@siggimund Жыл бұрын
  • Wow, well done Tim. I often had trouble explaining this to younger folks clearly. From now on, I'll just forward them to this video...

    @stomic50@stomic504 жыл бұрын
    • Thanks! I'm glad it was so clear.

      @IAmTimCorey@IAmTimCorey4 жыл бұрын
  • why are you so great? I come from C++ background. It was the language I grew up with and got used to programming being so difficult(and the community being so aggressive) but ever since my first programming job introduced me to C# I just kept getting amazed at how much friendly and easy C# is, both as in the community and the way it was developed, and you're part of what makes it great. I hope you don't stop making C# videos, any time soon, because a lot of times I just watch them because I like watching you explain things :)

    @branimirkobescak7769@branimirkobescak77693 жыл бұрын
    • I appreciate the kind words. I am glad my content has been so helpful and encouraging.

      @IAmTimCorey@IAmTimCorey3 жыл бұрын
  • what are the potential benefits of using the native async implementation of a method (download website in this case) instead of just wrapping the synchronous?

    @path_selector@path_selector Жыл бұрын
    • Really good question.

      @bennysaa@bennysaa Жыл бұрын
    • There are a few. First, an async-native method can properly handle a cancellation token. That means you can cancel long-running tasks, stuck tasks, etc. You cannot do this with converted methods. Second, an async-native application knows how to interact with other resources while in another thread. Synchronous methods assume they are on the same thread as the UI so they may interact with the UI or other resources. That can cause threading issues.

      @IAmTimCorey@IAmTimCorey Жыл бұрын
  • Very complicated. Thanks for making it, I appreciate that but if you are new to async this won't work as a tutorial. I think starting from a blank code will be better.

    @crabjuice47@crabjuice473 жыл бұрын
    • This basically was a "blank slate" project. The only things I did were to get a basic UI together so you didn't need to watch that and I created some basic code to call that was expensive. That "expensive" code can be anything you want and you don't even need to know what it does. The only way I could have done that with any less would be if I had built those two things on screen (but you would not have gotten anything else out of it since I explained both at the beginning), so it would have made the video longer but not added any real value to the topic.

      @IAmTimCorey@IAmTimCorey3 жыл бұрын
    • @@IAmTimCorey I think you would have been better off explaining the logic before showing examples, actually.

      @Printoiid@Printoiid2 жыл бұрын
    • Is it a good idea to measure time of the internet speed when wanne show the function of tasks

      @spaceengineersmods@spaceengineersmods2 жыл бұрын
  • Thanks for the video Tim! I finally got better understanding how to use it on practice. That's why I like your videos - you have a talent to explain quite difficult topics using simple, yet very detailed examples. Keep on doing your great job!

    @innokmikhalev7602@innokmikhalev76025 жыл бұрын
    • Excellent! I'm glad you have a better understanding now.

      @IAmTimCorey@IAmTimCorey5 жыл бұрын
    • Stupid people talk about easy things complicated and smart people talk easy about hard things.

      @kovalenkoihor4325@kovalenkoihor43255 жыл бұрын
  • Tim, excellent examples showing the two major advantages to asynchronous code. Many thanks, Harvey

    @harvb5939@harvb5939 Жыл бұрын
    • You are welcome.

      @IAmTimCorey@IAmTimCorey Жыл бұрын
  • I still am confused: does the calling thread wait or continue while await is working?!

    @raus_mit_Islam@raus_mit_Islam2 жыл бұрын
    • That particular method waits when you call "await" but it releases the thread back to the caller (usually the UI) to continue doing other work as long as that work doesn't depend on the results of the await.

      @IAmTimCorey@IAmTimCorey2 жыл бұрын
    • @@IAmTimCorey Q1: the released thread will join other yet not used threads, thus decreasing the risk that the appl runs out of threads? Or, will it immediately be assigned to specific work? Q2: given that the await’ed flow (fx of reading a file or performing a HTTP request) is without a thread, what ressource does it have? Reading from a file still needs processor power and RAM I suppose.

      @raus_mit_Islam@raus_mit_Islam2 жыл бұрын
  • That moment while working on a project when you don't remember stuff and go straight to Tim Corey

    @nicolamarizza1521@nicolamarizza15213 жыл бұрын
    • I am glad my content is that helpful.

      @IAmTimCorey@IAmTimCorey3 жыл бұрын
    • @@IAmTimCorey it is..

      @Greviouss@Greviouss3 жыл бұрын
  • Thank you so much. The only tutorial that made me understand properly, and I really like that fact that you explain that this is demo and not for production.

    @SuperChrisDub@SuperChrisDub6 ай бұрын
    • I am glad it was helpful.

      @IAmTimCorey@IAmTimCorey6 ай бұрын
  • Hi Tim, thanks for this amazing video. You have simplified this to such a basic level that even I could understand. One of the mysteries of the world is now solved for me. Cheers San.

    @MustBMusik@MustBMusik3 жыл бұрын
    • I am glad it was helpful!

      @IAmTimCorey@IAmTimCorey3 жыл бұрын
  • 13 minutes to explain the overly complicated demo program before even starting to talk about async.

    @haydengalloway5177@haydengalloway51772 жыл бұрын
    • Context is important, as is not leaving anyone behind. If you are unsure of the starting position, you won't be able to grasp where we go.

      @IAmTimCorey@IAmTimCorey2 жыл бұрын
    • @@IAmTimCorey Also you didn't talk about one of the most important points of confusion about using async. The dreaded "A method was called at an unexpected time" exception.

      @haydengalloway5177@haydengalloway51772 жыл бұрын
    • You don't get that message if you follow my instructions. That message happens because you don't properly await a call.

      @IAmTimCorey@IAmTimCorey2 жыл бұрын
    • @@IAmTimCorey I felt that the context explanation was very helpful. Thank you so much for the awesome work you do 🙏🙏🙏

      @Antonio-lt1sp@Antonio-lt1sp2 жыл бұрын
  • Great, easy to understand video. I like your pace and your explanation on each step. You made it look so easy. Till now I was confused when to use Task.Run() and when not to use. This video explained in a great way. Thank you so much Mr Corey.

    @anandvgchennai1974@anandvgchennai19744 жыл бұрын
    • Awesome!

      @IAmTimCorey@IAmTimCorey4 жыл бұрын
  • Your lessons worth tens of books and dozens of universities, THANK YOU Tim

    @aksands9929@aksands99293 жыл бұрын
    • I am glad my content has been helpful.

      @IAmTimCorey@IAmTimCorey3 жыл бұрын
KZhead