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

Sdílet
Vložit
  • čas přidán 2. 06. 2024
  • 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

Komentáře • 2,2K

  • @FunnySubmarine-ij4zk
    @FunnySubmarine-ij4zk Před měsícem +7

    Mr. Tim, One of the advantages of C# is that you teach it.

  • @dirkvaneester2946
    @dirkvaneester2946 Před 4 lety +124

    Tim, Thanks. This is the only "usable" explanation I found about async programming.

    • @IAmTimCorey
      @IAmTimCorey  Před 4 lety +9

      I am glad it was helpful.

    • @camdynvalentin9051
      @camdynvalentin9051 Před 2 lety

      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
      @camdynvalentin9051 Před 2 lety

      @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
      @camdynvalentin9051 Před 2 lety

      @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 !

    • @pedrojames6149
      @pedrojames6149 Před 2 lety

      @Camdyn Valentin happy to help :D

  • @zoran123456
    @zoran123456 Před 4 lety +47

    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.

    • @IAmTimCorey
      @IAmTimCorey  Před 4 lety +1

      Awesome! I am glad my videos are still helpful.

    • @b213videoz
      @b213videoz Před 2 lety +1

      One can, but probably two can't

  • @TheMedicinMannen
    @TheMedicinMannen Před 3 lety +4

    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

  • @jeffwang1715
    @jeffwang1715 Před 3 lety +4

    The best one that I've seen. Impressed how you can explain such a complicated concept in such a simple way!

  • @thesophisticatedvelocirapt7320

    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

  • @briank.daniels7939
    @briank.daniels7939 Před 3 lety +4

    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!

  • @EvanDear
    @EvanDear Před 5 lety +5

    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.

  • @devvorpian7255
    @devvorpian7255 Před 11 měsíci +3

    The best informative channel I've ever seen about programming... Thanks a lot sir!

  • @0lay3mi
    @0lay3mi Před 4 lety +3

    Even after one year, and this is still my best explanation of async/await in C#. Thank you, Tim.

  • @shaynemurray6351
    @shaynemurray6351 Před 6 lety +2

    Great work Tim, I like the way you overview the basics first then come back & drill down. You are a gifted teacher.

  • @louisbroucke2990
    @louisbroucke2990 Před 3 lety +1

    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!

    • @IAmTimCorey
      @IAmTimCorey  Před 3 lety +1

      I am glad my content is so helpful.

  • @jeffg4686
    @jeffg4686 Před 5 lety +3

    Best video on tasks I've seen so far. Not confusing in the slightest anymore.

  • @josephpatchen3421
    @josephpatchen3421 Před 2 lety +5

    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!

  • @eltoncastrosousa
    @eltoncastrosousa Před 5 lety +1

    Fantastic class. I've been studying this subject for a long time, but never found so clean and straightforward explanation. Congrats!!!

  • @esdenaze
    @esdenaze Před 3 lety +1

    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!

  • @Ricks_Shorts
    @Ricks_Shorts Před 4 lety +5

    The best and clearest explanation of async/await I have ever seen. Look forward to watching some of your other videos.

  • @MichaelHortonNow
    @MichaelHortonNow Před 2 lety +3

    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!

  • @mohamedmotaz1116
    @mohamedmotaz1116 Před 3 lety +2

    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!

  • @tomc2534
    @tomc2534 Před 4 lety +2

    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!

  • @muratkabak6212
    @muratkabak6212 Před 3 lety +3

    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 .

    • @tomthelestaff-iamtimcorey7597
      @tomthelestaff-iamtimcorey7597 Před 3 lety

      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!

  • @napstericious
    @napstericious Před rokem +3

    Straight to the point and easy to understand. You've got yourself another sub. Thank you for your time and effort put into this! :)

  • @hectorhenry9841
    @hectorhenry9841 Před 4 lety +1

    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!

    • @IAmTimCorey
      @IAmTimCorey  Před 4 lety

      You are most welcome. Thanks for watching.

  • @soucianceeqdamrashti8175
    @soucianceeqdamrashti8175 Před 4 lety +2

    Really cool that you showed how to run things in parrallell as well and explained the difference. Best video I have seen on async!

  • @truptibaliarsingh5441
    @truptibaliarsingh5441 Před 2 lety +3

    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.

  • @claya1532
    @claya1532 Před 2 lety +3

    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

  • @godfathermikal
    @godfathermikal Před 5 lety +2

    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!

    • @IAmTimCorey
      @IAmTimCorey  Před 5 lety

      Awesome! I'm glad it has been so helpful.

  • @EnergizerTX
    @EnergizerTX Před 2 měsíci +2

    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...

  • @kalvinwei19
    @kalvinwei19 Před 3 lety +3

    Thank you Tim. I was desperately looking for enlightenment of async on C#

  • @MindBodyMeditate
    @MindBodyMeditate Před 4 lety +11

    Dude, you're wicked. I always expect a video from that Indian guy but then you come through.

    • @IAmTimCorey
      @IAmTimCorey  Před 4 lety +2

      I'm assuming that's a good thing. :-)

  • @jaimecanoramos5207
    @jaimecanoramos5207 Před 2 lety +2

    Probably one of the best tutorials for async out there, if not the best.
    Really good job!

  • @david3552
    @david3552 Před 2 lety +2

    You and your videos are fantastic. Learning async using the offical documentation felt kind of daunting and convoluted. You made it clear!

  • @KleineDrehmomente
    @KleineDrehmomente Před 2 lety +4

    Absolutly great tutorial. Finally I understood the async procedure. Thanks a lot !

  • @MrLilleblomst
    @MrLilleblomst Před 4 lety +4

    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!

  • @danielsauter5326
    @danielsauter5326 Před 4 lety +1

    Really enjoyed the clear and concise explanation. I've seen asynchronous code many times but this really made things crystal clear

  • @ronaldolds1034
    @ronaldolds1034 Před 3 lety +1

    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.

    • @IAmTimCorey
      @IAmTimCorey  Před 3 lety

      Thanks for the nice comments. I strive to educate, not just show examples. It does seem to be helping a lot of folks.

    • @ronaldolds1034
      @ronaldolds1034 Před 3 lety

      @@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

  • @RalfsBalodis
    @RalfsBalodis Před 3 lety +8

    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

    • @IAmTimCorey
      @IAmTimCorey  Před 3 lety +3

      Thanks! I added it to the description.

  • @ted88
    @ted88 Před 5 lety +3

    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)

    • @IAmTimCorey
      @IAmTimCorey  Před 5 lety

      Excellent! I'm glad it was so helpful to you.

  • @HarveyMyers
    @HarveyMyers Před 2 lety +1

    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.

    • @IAmTimCorey
      @IAmTimCorey  Před 2 lety

      You are most welcome. Thanks for watching.

  • @RaquelSofiaUni
    @RaquelSofiaUni Před 2 lety +1

    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!

  • @gauravparvat5291
    @gauravparvat5291 Před 6 lety +4

    The best explanation of Async Await by far without a lot of fuss and confusing terms!!!

  • @nathanielriehl623
    @nathanielriehl623 Před 5 lety +2

    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!

    • @IAmTimCorey
      @IAmTimCorey  Před 5 lety

      Awesome! I'm glad it finally clicked.

  • @davidyue6310
    @davidyue6310 Před 5 lety

    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!!

  • @leonsoares7405
    @leonsoares7405 Před 4 lety +3

    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!

    • @IAmTimCorey
      @IAmTimCorey  Před 4 lety

      You are most welcome. Thanks for watching.

  • @longuinni
    @longuinni Před 6 lety +3

    The best asynchronous programming video on CZcams!!

  • @SuperChrisDub
    @SuperChrisDub Před 7 měsíci +2

    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.

  • @raskand1977
    @raskand1977 Před 6 lety +1

    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!

    • @IAmTimCorey
      @IAmTimCorey  Před 6 lety +1

      Awesome! I am glad you found it so valuable.

  • @advaitharmy
    @advaitharmy Před 3 lety +5

    You are brilliant in teaching sir 🙏🏼

  • @CodeZeeZ
    @CodeZeeZ Před 3 lety +3

    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.

    • @tomthelestaff-iamtimcorey7597
      @tomthelestaff-iamtimcorey7597 Před 3 lety

      Thanks for watching and trusting Tim to be a part of your coding journey.

    • @sparking023
      @sparking023 Před 3 lety +1

      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 :)

  • @northernpanda6953
    @northernpanda6953 Před 3 lety

    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.

  • @yairashkenazi5455
    @yairashkenazi5455 Před 4 lety +2

    Hi Tim,
    You're an amazing teacher, and I enjoy your tutorials very much. Thanks a lot and keep up the good work!

  • @alexzinkevych3596
    @alexzinkevych3596 Před 4 lety +4

    Wow, this is pretty much like async/await and Promise in JS. The video was really easy to understand with that in mind.

  • @dewaldgroenewald5711
    @dewaldgroenewald5711 Před 4 lety +4

    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.

  • @henriquejvalho
    @henriquejvalho Před 6 lety +2

    Best explanation about Async / Await I've ever seen! Thank you.

  • @weizhen77
    @weizhen77 Před 5 lety +1

    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.

    • @IAmTimCorey
      @IAmTimCorey  Před 5 lety

      You are most welcome. Thanks for watching.

  • @logix8969
    @logix8969 Před 4 lety +5

    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 :)

    • @IAmTimCorey
      @IAmTimCorey  Před 4 lety

      I am glad you got some value out of the video.

  • @FranChen1984
    @FranChen1984 Před 5 měsíci +3

    Your voice and English accent are good. Few of vedios that not hurt my ears!Thanks!

    • @IAmTimCorey
      @IAmTimCorey  Před 5 měsíci +1

      You are welcome.

    • @LaurentChabenet
      @LaurentChabenet Před 5 měsíci +1

      Also few comments that don't hurt my eyes 😁

    • @trustingod0
      @trustingod0 Před 5 měsíci

      Yeah great 🎤. By the way what model mic are you using I want to start making some tutorials

  • @bigchunk1
    @bigchunk1 Před 4 lety

    I like the recap at the end. I was expecting to have to go over the video multiple times to understand it, but the recap helped a lot.

  • @christopherkreitlow1178
    @christopherkreitlow1178 Před 5 lety +2

    A great, simple explanation of the fundamentals of a complex topic. Thanks!

  • @KarChunChua
    @KarChunChua Před 2 lety +4

    Great explanation and demo!

  • @atnguyen5442
    @atnguyen5442 Před 4 lety +3

    Best channel to learn c#. Wish I known it earlier

  • @anandvgchennai1974
    @anandvgchennai1974 Před 4 lety +1

    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.

  • @mcopy9p350
    @mcopy9p350 Před 3 lety +1

    I recently started following your courses!! Such a wonderful coaching.. thanks for your time and videos... Love you teaching from India.

    • @IAmTimCorey
      @IAmTimCorey  Před 3 lety

      Awesome! I am glad you are enjoying my videos.

  • @thebigmoon8372
    @thebigmoon8372 Před rokem +5

    I'm wondering... Why do i find this video only now??? Thank you so much. It was so easy to understand it with you

  • @KyleWestendorf
    @KyleWestendorf Před 6 lety +3

    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.

    • @IAmTimCorey
      @IAmTimCorey  Před 6 lety +3

      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.

  • @qapolo9196
    @qapolo9196 Před 4 lety

    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.

  • @charlesdodson829
    @charlesdodson829 Před 5 lety +1

    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".

    • @IAmTimCorey
      @IAmTimCorey  Před 5 lety

      Awesome! I'm glad it was clear and enjoyable.

  • @kartikk7402
    @kartikk7402 Před 5 lety +3

    Best video on async await.

  • @dand4485
    @dand4485 Před 4 lety +3

    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 :)

    • @dennisekkelenkamp2303
      @dennisekkelenkamp2303 Před 4 lety

      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.

    • @dand4485
      @dand4485 Před 4 lety

      @@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!

    • @IAmTimCorey
      @IAmTimCorey  Před 4 lety +1

      Nice job both of you. I'm glad to see you both contributing positively to the community. Thanks for watching.

  • @innokmikhalev7602
    @innokmikhalev7602 Před 5 lety +1

    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!

    • @IAmTimCorey
      @IAmTimCorey  Před 5 lety +1

      Excellent! I'm glad you have a better understanding now.

    • @kovalenkoihor4325
      @kovalenkoihor4325 Před 5 lety

      Stupid people talk about easy things complicated and smart people talk easy about hard things.

  • @samanson2001
    @samanson2001 Před 2 měsíci +2

    Finally a video that explains some of the different applications of async. Never understood it previously as I just thought what's the difference if you're awaiting on things.

  • @mekkanikmike
    @mekkanikmike Před 2 lety +5

    Six months of frustration, 25 mins of tim corey (sorry I watch at 1.5x :D ...) to solve it.

  • @chadiusmaximus9350
    @chadiusmaximus9350 Před 2 lety +3

    Great video, you explain things very well. I think, however, your parallel method isn't actually running parallel rather its running concurrently.

    • @IAmTimCorey
      @IAmTimCorey  Před 2 lety +3

      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.

    • @chadiusmaximus9350
      @chadiusmaximus9350 Před 2 lety +1

      @@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.

  • @david-xw4ug
    @david-xw4ug Před rokem +2

    Can't believe I understood ever word in the video! Thank you for the excellent work!

  • @lyndondoliveiro5941
    @lyndondoliveiro5941 Před 4 lety +2

    Very well explained. This is not the first time Tim Corey has been very helpful

  • @codefoxtrot
    @codefoxtrot Před rokem +3

    Thanks!

  • @Octavius145
    @Octavius145 Před 2 lety

    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!

  • @reynoldmonares179
    @reynoldmonares179 Před 3 lety +2

    Thank you so much Tim. These really helped me understand async await better than the other youtube videos. It really helped me.

  • @timkaiser3820
    @timkaiser3820 Před 2 lety +3

    Wichtig und richtig.

  • @otkirbeksobirjonov9695
    @otkirbeksobirjonov9695 Před 2 lety +3

    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 ?

    • @IAmTimCorey
      @IAmTimCorey  Před 2 lety +1

      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.

  • @Chapali9a
    @Chapali9a Před 3 lety +1

    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.

  • @RoundTheCode
    @RoundTheCode Před 3 lety

    Very clear video. Async is a little tricky at first, but once you get your head around it, it's simple to use & very effective on improving the speed of an application.

  • @sashithafonseka
    @sashithafonseka Před rokem +3

    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?

    • @IAmTimCorey
      @IAmTimCorey  Před rokem +4

      Because the method cannot communicate a failure to you.

    • @jonathanharmon3472
      @jonathanharmon3472 Před rokem +1

      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.

    • @sashithafonseka
      @sashithafonseka Před rokem

      @@jonathanharmon3472 and @IAmTimCorey thank you for the clarification!

  • @wildKawa
    @wildKawa Před rokem +3

    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!

    • @siggimund
      @siggimund Před rokem

      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.

  • @dannyellenbogen9275
    @dannyellenbogen9275 Před 6 lety +1

    Thanks Tim for another great tutorial, you really know how to simplify confusing stuff and show the easy practical road for developing successful applications.

    • @IAmTimCorey
      @IAmTimCorey  Před 6 lety

      I'm glad I was able to cut through the confusion for you.

  • @efezaladin3236
    @efezaladin3236 Před 4 lety

    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!

  • @path_selector
    @path_selector Před rokem +3

    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?

    • @bennysaa
      @bennysaa Před rokem +1

      Really good question.

    • @IAmTimCorey
      @IAmTimCorey  Před rokem +5

      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.

  • @engineerchaos8424
    @engineerchaos8424 Před rokem +3

    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.

  • @raus_mit_Islam
    @raus_mit_Islam Před 2 lety +3

    I still am confused: does the calling thread wait or continue while await is working?!

    • @IAmTimCorey
      @IAmTimCorey  Před 2 lety +2

      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.

    • @raus_mit_Islam
      @raus_mit_Islam Před 2 lety

      @@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.

  • @razzer57
    @razzer57 Před 2 lety

    This is the best video tutorial on "async / await" I have ever seen!!! thank you so much Tim

  • @walius1988
    @walius1988 Před 3 lety +1

    Because of your videos, I am getting better and better in C#. Thank you a lot!

  • @adiac42
    @adiac42 Před rokem +3

    This video about Async was legen... wait for it ...daryAsync!

  • @crabjuice47
    @crabjuice47 Před 3 lety +3

    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.

    • @IAmTimCorey
      @IAmTimCorey  Před 3 lety

      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.

    • @Printoiid
      @Printoiid Před 3 lety

      @@IAmTimCorey I think you would have been better off explaining the logic before showing examples, actually.

    • @spaceengineersmods
      @spaceengineersmods Před 3 lety

      Is it a good idea to measure time of the internet speed when wanne show the function of tasks

  • @dineshsingag
    @dineshsingag Před 5 měsíci

    Really liked the video - a good starter for someone like me, who have just started exploring ansynchronus programming stuff!

  • @LostConjugate
    @LostConjugate Před 6 lety

    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!

    • @IAmTimCorey
      @IAmTimCorey  Před 6 lety

      Excellent! I'm glad you were able to apply it right away.

  • @nicolamarizza1521
    @nicolamarizza1521 Před 3 lety +5

    That moment while working on a project when you don't remember stuff and go straight to Tim Corey

  • @haydengalloway5177
    @haydengalloway5177 Před 2 lety +4

    13 minutes to explain the overly complicated demo program before even starting to talk about async.

    • @IAmTimCorey
      @IAmTimCorey  Před 2 lety +8

      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.

    • @haydengalloway5177
      @haydengalloway5177 Před 2 lety

      @@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.

    • @IAmTimCorey
      @IAmTimCorey  Před 2 lety +6

      You don't get that message if you follow my instructions. That message happens because you don't properly await a call.

    • @Antonio-lt1sp
      @Antonio-lt1sp Před 2 lety +3

      @@IAmTimCorey I felt that the context explanation was very helpful. Thank you so much for the awesome work you do 🙏🙏🙏

  • @lastidea4925
    @lastidea4925 Před 2 lety +2

    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! ❤

  • @klasidarlang-larsen1907
    @klasidarlang-larsen1907 Před 5 lety +1

    Awesome video Tim. As always, your educational skills are top notch!

  • @Classicv5
    @Classicv5 Před 5 lety +1

    Much more clear than all of the examples I’ve seen floating around. Finally think I can put this to use!