Stack Undefined
Stack Undefined

Reputation: 1350

Long running service for scheduled jobs in .NET 6

I will be using .NET 6 for a project that will execute scheduled jobs. I don't want to run the service as a Windows or Linux service. No while loop or Task.Delay hack should be used. I'm planning to use Quartz.NET for scheduling but not the concern at the moment. The background worker and IHostedService implementations I've seen so far all use the while loop. I think Quartz.NET has a host I can use and most likely they are using a while loop and/or task.delay behind the scenes. If I have to use their host, I will as a last resort. What project types are available in .NET 6 so the service stays on while periodically executing tasks until shutdown (not asp.net)?

Upvotes: 0

Views: 89

Answers (1)

oleksii
oleksii

Reputation: 35935

What project types are available in .NET 6 so the service stays on while periodically executing tasks until shutdown

It is called a service/daemon. It will handle security using native OS capabilities, power transitions, auto-starting in case of a reboot or abnormal app termination.

I would also look at writing a trivial app(s) to do the job and delegate scheduling to other modules like cron or similar tools depending on your automation level and deployment platform. A long-running process tends to accumulate more errors and hold onto more resources compared to short-lived processes that are scheduled from the outside.

Upvotes: 0

Related Questions