Class SchedulerJobExtensions
- Namespace
- Quartz
- Assembly
- Quartz.dll
Scheduling a job by its type, the way the container-configured builder does.
public static class SchedulerJobExtensions
- Inheritance
-
SchedulerJobExtensions
- Inherited Members
Remarks
Extensions rather than IScheduler members: they compose JobBuilder, TriggerBuilder and the scheduler's own operations, and need nothing an implementation could do better, so every scheduler — including one written outside this repository — gets them without having to write them.
Methods
ScheduleJob<TJob>(IScheduler, ITrigger, Action<IJobConfigurator<TJob>>?, CancellationToken)
Schedule a job of the given type with the given trigger, building the IJobDetail along the way.
public static ValueTask<DateTimeOffset> ScheduleJob<TJob>(this IScheduler scheduler, ITrigger trigger, Action<IJobConfigurator<TJob>>? configure = null, CancellationToken cancellationToken = default) where TJob : IJob
Parameters
schedulerISchedulerthe scheduler to schedule the job with.
triggerITriggerthe trigger that fires the job.
configureAction<IJobConfigurator<TJob>>configures the job; omit to take everything from the type and the trigger.
cancellationTokenCancellationTokenThe cancellation instruction.
Returns
- ValueTask<DateTimeOffset>
the first time at which the trigger will fire.
Type Parameters
TJobthe type of the job to schedule.
Remarks
The imperative twin of q.ScheduleJob<TJob>(...) on IQuartzBuilder,
so that scheduling a job at run time reads like declaring one at start-up and neither has to
name a JobBuilder.
The job's identity is the first of these that exists: the one
configure gave it, the one trigger already points at
through JobKey, or the trigger's own key. Naming neither is therefore
enough to schedule the pair, and a trigger built with ForJob still gets the job it
asked for.
ScheduleJob<TJob, TInput>(IScheduler, TInput, DateTimeOffset, OneOffJobOptions, CancellationToken)
Schedules one firing of TJob with the given payload, at the given time.
public static ValueTask<ScheduledOneOffJob> ScheduleJob<TJob, TInput>(this IScheduler scheduler, TInput input, DateTimeOffset at, OneOffJobOptions options = default, CancellationToken cancellationToken = default) where TJob : IJob<TInput>
Parameters
schedulerISchedulerThe scheduler to schedule on.
inputTInputThe payload the firing carries, put on the trigger.
atDateTimeOffsetWhen the job should run.
optionsOneOffJobOptionsThe trigger's identity and the rest of what can be said about one firing.
cancellationTokenCancellationTokenThe cancellation instruction.
Returns
- ValueTask<ScheduledOneOffJob>
The trigger that was stored and the time it will first fire.
Type Parameters
TJobThe job to fire.
TInputThe payload's type, inferred from
input.
ScheduleJob<TJob, TInput>(IScheduler, TInput, TimeSpan, OneOffJobOptions, CancellationToken)
Schedules one firing of TJob with the given payload, at the given time.
public static ValueTask<ScheduledOneOffJob> ScheduleJob<TJob, TInput>(this IScheduler scheduler, TInput input, TimeSpan delay, OneOffJobOptions options = default, CancellationToken cancellationToken = default) where TJob : IJob<TInput>
Parameters
schedulerISchedulerThe scheduler to schedule on.
inputTInputThe payload the firing carries, put on the trigger.
delayTimeSpanHow long from now the job should run.
optionsOneOffJobOptionsThe trigger's identity and the rest of what can be said about one firing.
cancellationTokenCancellationTokenThe cancellation instruction.
Returns
Type Parameters
TJobTInput
Remarks
"Now" is TimeProvider, so a delay is measured against the same clock the scheduling loop will compare it to.