Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
27 lines (17 sloc) 1.38 KB

Calling methods with delay

Sometimes you may want to postpone a method invocation; for example, to send an email to newly registered users a day after their registration. To do this, just call the BackgroundJob.Schedule method and pass the desired delay:

    () => Console.WriteLine("Hello, world"),

:doc:`Hangfire Server <../background-processing/processing-background-jobs>` periodically checks the schedule to enqueue scheduled jobs to their queues, allowing workers to execute them. By default, check interval is equal to 15 seconds, but you can change it by setting the SchedulePollingInterval property on the options you pass to the BackgroundJobServer constructor:

var options = new BackgroundJobServerOptions
    SchedulePollingInterval = TimeSpan.FromMinutes(1)

var server = new BackgroundJobServer(options);

If you are processing your jobs inside an ASP.NET application, you should perform the following steps to ensure that your scheduled jobs get executed at the correct time:

You can’t perform that action at this time.