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.
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!
@@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...
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!
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.
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!
@@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...
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 😅
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?
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!
You forgot to dispose the newly created scope
Ouch, you are correct!
why do the actions need to be scoped?
Yeah, I missed saying that! The reason is that you can now inject any scoped service into your action class (efcontext, repository, ..)