Fixing sync over async issues in .NET / C# with Visual Studio 2022

Поділитися
Вставка
  • Опубліковано 2 лют 2025

КОМЕНТАРІ • 25

  • @jhbonarius
    @jhbonarius 3 роки тому +33

    the problem is in legacy applications, where you cannot make the calling method async. like old webforms. sometimes you need a task.run to prevent a deadlock.

  • @iceangel564
    @iceangel564 3 роки тому +15

    What to do when you got problem with calling async method from sync? Just stop having problem, don't call it, fantastic solution

  • @stefanvestergaard
    @stefanvestergaard 3 роки тому +20

    That is by far the worst fix of a problem I have ever seen. Solution: "Don't have the problem to begin with".

  • @obiwanjacobi
    @obiwanjacobi 3 роки тому +23

    So basically there is no fix for calling an async method from a sync context on the same thread...?

    • @j2pnation
      @j2pnation 3 роки тому +6

      The key is to go back in time and never write any sync APIs in the first place.

    • @Anton-dl7me
      @Anton-dl7me 3 роки тому +3

      yeah but when u r to incorporate some newer libs to ur legacy code. It always produces stuff like that. Even may cause deadlocks

  • @LDdrums20
    @LDdrums20 3 роки тому +12

    Dude is a bassist. Got to respect him

  • @innovationscode9909
    @innovationscode9909 3 роки тому

    Awesome. Keep it going.

  • @joebeattie4234
    @joebeattie4234 2 роки тому

    how do you know the result is OK if you do not look at what came back from the async call? could be a number of errors right?

  • @Peter_M
    @Peter_M 3 роки тому +1

    but asynchronous does not mean multithreading. We do not know in which thread will our async code run. Or am i wrong?

  • @screamer220v
    @screamer220v 3 роки тому

    Thnks man you are a magician!!

  • @throngler4589
    @throngler4589 3 роки тому +1

    If you really wanted to call asynchronous methods from sync methods, isnt there a way to make it run on the calling thread to act as a sync method?

  • @zoran123456
    @zoran123456 3 роки тому +9

    As others were already pointed out, this is completely useless information. We already know the benefits of using async over non async API calls. It is known for many years now. I don't really understand what does it have to do with VS 2022 or "fixing sync over async issues", as you didn't had any code to fix. You intentially created a bad code. Issues are not in the API-s, but on the legacy 3rd party libraries which are usually not asynchronous.

    • @marcotroster8247
      @marcotroster8247 3 роки тому +1

      It's very important to get informed about code linting metrics and coding flaws 😜 How would you justify a redesign when having to clean up messy codebases? 🙈 (just joking, but actually happened in my last project. Glad I'm out there ...)

    • @timmcgee1339
      @timmcgee1339 9 місяців тому

      No graceful backward compatibility? Our application suite is 6.5 million lines of code that worked flawlessly at very high volume. Now it doesn't on the same code. You don't find out until its under heavy load. A garbage solution by MS.

  • @---bi6ne
    @---bi6ne 3 роки тому

    what is the font of the editor?

  • @Jirkass4
    @Jirkass4 3 роки тому +1

    Very helpful. Thanks! Also cool name mr. Markdown.

  • @jhbonarius
    @jhbonarius 3 роки тому

    why is the analyzer a nuget package and not a vs extension? do I need to add it to every project in my solution? is there a production performance overhead?

    • @sevensolutions77
      @sevensolutions77 3 роки тому +3

      I think this is just a compile-time tool, so there shouldnt be any runtime overhead but i havent checked it out yet. Nuget packages may also contain tools.

  • @martinrj30
    @martinrj30 3 роки тому

    TLDR; change all sync to async. No help to maintainers of fixed Interfaces.

  • @pixel7038
    @pixel7038 3 роки тому

    Make it available in linux please

  • @pranavraj5698
    @pranavraj5698 3 роки тому

    koi use bhi karta c# ab

    • @sumanpanda157
      @sumanpanda157 3 роки тому +3

      Has bass 25% developers worldwide.