I have serivce which has some method which I would like to be Recurring job.
I know that I can use hangfire in my Startup.cs e.g:
RecurringJob.AddOrUpdate(() => Console.WriteLine("I'm a recurring job"), Cron.Minutely);
But the question is how can I use my services here? Should I use somehow here (dependency injection ?) or in the other place?
Maybe should I put some cron values to the appsettings.json ?
The downside of hangfire I fet was the complexity in the setting it up. It needs few extra tables to set up for it to work. I hope you have the tables created for it in your database. Pls see this how to get the recurring jobs.- HangFire recurring task data. I feel it is very good for queuing jobs or for background tasks but for recurring jobs, I would suggest to go for Quartz.net. It needs no such setting up and very easy to integrate. No problems so far and it has good CRON support. Example - https://www.mikesdotnetting.com/article/254/scheduled-tasks-in-asp-net-with-quartz-net