I'm developing an application in C# MVC and I want to execute multiple background tasks each at different time intervals. I already have a service that inherits the class BackgroundService.
I already tried following this tutorial, but that only works if u only have 1 task.
Do you need a separate service for each task?
There are multiple options here:
The official documentation shows the option to create a Timed background tasks:
You can use this approach with several timers.
You can just start several tasks in the
ExecuteAsync:Use different hosted services, one per task (personally my go to option in this case)
Also consider switching some scheduling libraries/frameworks like Hangfire or Quartz.NET