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

Поділитися
Вставка
  • Опубліковано 20 гру 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 UA-cam 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!
  • Наука та технологія

КОМЕНТАРІ • 15

  • @yehudak1646
    @yehudak1646 3 місяці тому

    Very useful information, Tank you very much.

  • @chrisevans9629
    @chrisevans9629 5 місяців тому +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 5 місяців тому

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

  • @janjoska2549
    @janjoska2549 5 місяців тому +13

    There is no thread, neo

  • @exciting-burp6613
    @exciting-burp6613 5 місяців тому +5

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

  • @jeffsherman9638
    @jeffsherman9638 4 місяці тому

    Thanks for sharing!

  • @farhadsu
    @farhadsu 5 місяців тому

    Good explanation. Thanks!

  • @turbosega
    @turbosega 5 місяців тому

    Nice!

  • @Onyxagargaryll
    @Onyxagargaryll 5 місяців тому

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

  • @tarsala1995
    @tarsala1995 4 місяці тому

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

  • @gregh2327
    @gregh2327 5 місяців тому +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 5 місяців тому +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 5 місяців тому +4

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