Interface IJob
- Namespace
- Quartz
- Assembly
- Quartz.dll
The interface to be implemented by classes which represent a 'job' to be performed.
public interface IJob
Remarks
An instance is built for each fire by the scheduler's IJobFactory, which by default resolves the job from the dependency-injection container — so a job's dependencies are ordinary constructor parameters, and there need be no parameterless constructor. JobDataMap provides a mechanism for 'instance member data' that may be required by some implementations of this interface.
Methods
Execute(IJobExecutionContext, CancellationToken)
Called by the IScheduler when a ITrigger fires that is associated with the IJob.
ValueTask Execute(IJobExecutionContext context, CancellationToken cancellationToken = default)
Parameters
contextIJobExecutionContextThe execution context.
cancellationTokenCancellationTokenSignalled when this execution is interrupted — either by Interrupt(JobKey, CancellationToken) or by the scheduler shutting down while configured to interrupt running jobs. A long-running job should pass this on to everything it awaits; a job that ignores it cannot be interrupted, and will hold up shutdown until it finishes on its own.
This is the same token as CancellationToken, given as a parameter so that it is impossible to miss and so that the compiler can point out where it has not been forwarded.
Returns
Remarks
The implementation may wish to set a result object on the JobExecutionContext before this method exits. The result itself is meaningless to Quartz, but may be informative to IJobListeners or ITriggerListeners that are watching the job's execution.