Reputation: 522
I have two recurring jobs.
First one calls MethodOne() every 20 seconds
Second one calls MethodTwo() every 20 seconds.
I want second one to start 1 minute after first method so they never start simultaneously.
currently, this is my code. It doesn't work because both jobs start at the same time.
RecurringJob.AddOrUpdate<MethodCaller>(a => a.MethodOne(), "*/20 * * * * *");
Thread.Sleep(60000);
RecurringJob.AddOrUpdate<MethodCaller>(a => a.MethodTwo(), "*/20 * * * * *");
Both MethodOne() and MethodTwo() are void. They both have one line of code.
Debug.Writeline("Method Called");
Upvotes: 0
Views: 181
Reputation: 36341
Using a regular System.Threading.Timer you can specify the due time and period separately. So you could have the same period, but different delays. Not familiar with Hangfire, so I cannot suggest how to use that to do the same thing.
Another option would be to let the first job trigger the second job.
Upvotes: 1