Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Scheduling a recurring job with Hangfire
public class HangfireJobScheduler
{
public void ScheduleHangfireJob()
{
RecurringJob.RemoveIfExists("myCustomJobId");
RecurringJob.AddOrUpdate(SyncJobId,
() => SyncEvents(),
Cron.MinuteInterval(2));
}
public void SyncEvents()
{
Console.WriteLine("Hello Hangfire"); // this code will be executed every 2 minutes
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.