Correcting Common Async/Await Mistakes in .NET 8 - Brandon Minnick - NDC Porto 2023

Sdílet
Vložit
  • čas přidán 20. 12. 2023
  • This talk was recorded at NDC Porto in Porto, Portugal. #ndcporto #ndcconferences #dotnet #concurrency #softwaredeveloper
    Attend the next NDC conference near you:
    ndcconferences.com
    ndcporto.com/
    Subscribe to our CZcams channel and learn every day:
    /@NDC
    Follow us on our Social Media:
    / ndcconferences
    / ndc_conferences
    / ndc_conferences
    Did you know that the .NET compiler turns our async methods into classes? And that .NET adds a try/catch block to each of these classes, potentially hiding thrown exceptions? It's true!
    In this session, we will learn how to best use async/await in C# by analyzing how .NET compiles our async code.
    Join me as we take an existing app and optimize its async code together, showing off performance gains, better exception handling, improved run-time speed, and smaller app size!
  • Věda a technologie

Komentáře • 15

  • @chrisevans9629
    @chrisevans9629 Před 4 měsíci +7

    A task really is just work that will be completed at a later time. In some contexts, it may not run on a different thread in the thread pool, although thread switching is the most common scenario. It never creates a thread as far as I am aware, but just cycles through the thread pool. Additionally, the primary goal of async/await is to free up the UI and to make background tasks easier, which is a different problem than parallel processing with different design considerations.

    • @VoroninPavel
      @VoroninPavel Před 4 měsíci

      > It never creates a thread as far as I am aware.
      Depends on the scheduler. In theory TaskCreationOptions.LongRunning signals to the scheduler that creating a new thread is desirable.

  • @yehudak1646
    @yehudak1646 Před 2 měsíci

    Very useful information, Tank you very much.

  • @exciting-burp6613
    @exciting-burp6613 Před 4 měsíci +5

    Missed the biggest problem with async void: unhandled exceptions will bring the entire process down (depending on the synchronization context).

  • @jeffsherman9638
    @jeffsherman9638 Před 3 měsíci

    Thanks for sharing!

  • @janjoska2549
    @janjoska2549 Před 4 měsíci +13

    There is no thread, neo

  • @farhadsu
    @farhadsu Před 4 měsíci

    Good explanation. Thanks!

  • @turbosega
    @turbosega Před 4 měsíci

    Nice!

  • @Onyxagargaryll
    @Onyxagargaryll Před 4 měsíci

    Great talk!
    How is the "available thread" chosen? Does .NET have a scheduler for this?

  • @gregh2327
    @gregh2327 Před 4 měsíci +9

    Brandon seems like a nice, friendly guy; but this talk on async/await that he keeps doing is flimsy at best and dangerous at worst. The conflation of threads and tasks being the most egregious mistake.
    “There’s a threadpool. We don’t have time to dive into it today” leads to so much bad, async code. Unfortunately, async/await is advanced stuff and hand waving the complexity away is problematic.

    • @oralitical
      @oralitical Před 4 měsíci +1

      Out of curiosity. Is there any resource you would recommend? I'd love to learn more about async/await specifically since it's such an abstract concept.

    • @djchrisi
      @djchrisi Před 4 měsíci +4

      @@oraliticalI think the post "There Is No Thread" from Stephen Cleary is a good start.

  • @tarsala1995
    @tarsala1995 Před 3 měsíci

    You cannot say that value types are leaving in the stack. It's a big oversimplification