The Right Way to Handle Multitenant Background Tasks in .NET

แชร์
ฝัง
  • เผยแพร่เมื่อ 11 ต.ค. 2024

ความคิดเห็น • 10

  • @ahupond
    @ahupond 2 หลายเดือนก่อน

    PLinq does multithreading which is appropriate for CPU operations such as crypto/maths. For IO operations it is easier and more efficient to use Task.WhenAll() with actions.Select() instead.

    • @mdbouk
      @mdbouk  2 หลายเดือนก่อน +1

      You are correct. My intention was to showcase PLINQ, but you are right that it might not be ideal for background services. However, PLINQ can still be useful for certain scenarios where you need to handle cancellation and exceptions in a more defined way.
      Thank you for pointing that out!

    • @ahupond
      @ahupond 2 หลายเดือนก่อน

      @@mdbouk .NET 9 introduces Task.WhenEach() for less straightforward asynchronous cases. Could be an interesting topic for a followup video regarding more indepth discussions regarding async/parallel, async enumerables, etc...

    • @mdbouk
      @mdbouk  2 หลายเดือนก่อน

      It is indeed an interesting topic. I will wait for .NET 9 to come out before making any videos, just to avoid any future changes 😅

  • @ahmadalsader1047
    @ahmadalsader1047 หลายเดือนก่อน

    what if i have something like CRON expression i would like to run service A and Service B with different timing without using something like Quartz?

    • @mdbouk
      @mdbouk  หลายเดือนก่อน +1

      In my other video on background services, I showed how to do that with fixed timer, CRON was planned to be part of that video but it got too big for a simple video. Probably I should revisit that in a separate one!
      Nice one!

  • @Curlack
    @Curlack 2 หลายเดือนก่อน +2

    You forgot to dispose the newly created scope

    • @mdbouk
      @mdbouk  2 หลายเดือนก่อน

      Ouch, you are correct!

  • @LindenMikus
    @LindenMikus 2 หลายเดือนก่อน

    why do the actions need to be scoped?

    • @mdbouk
      @mdbouk  2 หลายเดือนก่อน

      Yeah, I missed saying that! The reason is that you can now inject any scoped service into your action class (efcontext, repository, ..)