Job Scheduler Management

To manage the scheduler use the IJobScheduler_.

Adding and Updating Jobs

The AddOrUpdateJob() method adds or updates a job information. By default added at runtime jobs are stored in the memory of the web server so they will be lost after restarting the application. To store jobs in a persistent storage you should install an implementation of the document storage or implement the IJobSchedulerRepository interface, then the jobs will be scheduled even after restarting the application. To add several jobs at once use the AddOrUpdateJobs() method. Also you can add a Paused job and not start planning it not immediately after the addition.

Deleting Jobs

The DeleteJob() method deletes the specified job. After that the job will be unscheduled and removed from the storage. Thus you cannot resume resume the job after its the deletion. Nonetheless, jobs are declared in the code will be stopped just until restarting the application. To delete several jobs at once use DeleteJobs() or DeleteAllJobs() methods.

Pausing Jobs

The PauseJob() method stops scheduling the specified job. To pause several jobs at once use PauseJobs() or PauseAllJobs() methods.

Resuming Jobs

The ResumeJob() method starts scheduling the specified job. To pause several jobs at once use ResumeJobs() or ResumeAllJobs() methods.

Triggering Jobs

The TriggerJob() method invokes processing the specified job despite its schedule. Before triggering a job make sure it is Planned. To trigger several jobs at once use TriggerJobs() or TriggerAllJob() methods.

Getting Job Scheduler Status

There are two additional methods getting the scheduler status: IsStarted() and GetStatus(). The IsStarted() method checks whether the scheduler is started and returns true if it is started. The GetStatus() method allows to check status of the current jobs.

IJobScheduler jobScheduler;

// ...

var plannedCount = await jobScheduler.GetStatus(i => i.Count(j => j.State == JobState.Planned));