I want to create background jobs declaratively, so I just add a new class to my assembly with an attribute I create defining the cron expression. I’m having a hard time figuring out how to add these recurring jobs. I think this works, but do I need to create a new REcurringJobManager() or does that cause an issue?
var job = new Job(type, method);
RecurringJobManager manager = new RecurringJobManager();
manager.AddOrUpdate($"{method.DeclaringType.Name}.{method.Name}", job, attr.Cron);
I see that is what RecurringJob.AddOrUpdate() does behind the scenes using it’s own RecurringJobManager instance, will creating new ones mess anything up, or is that just to communicate with storage to create the job? When I hear ‘RecurringJobManager’ I think it would handle everything with recurring jobs and that I shouldn’t create a new instance of it.