Table of Contents

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

scheduler IScheduler

the scheduler to schedule the job with.

trigger ITrigger

the trigger that fires the job.

configure Action<IJobConfigurator<TJob>>

configures the job; omit to take everything from the type and the trigger.

cancellationToken CancellationToken

The cancellation instruction.

Returns

ValueTask<DateTimeOffset>

the first time at which the trigger will fire.

Type Parameters

TJob

the 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

scheduler IScheduler

The scheduler to schedule on.

input TInput

The payload the firing carries, put on the trigger.

at DateTimeOffset

When the job should run.

options OneOffJobOptions

The trigger's identity and the rest of what can be said about one firing.

cancellationToken CancellationToken

The cancellation instruction.

Returns

ValueTask<ScheduledOneOffJob>

The trigger that was stored and the time it will first fire.

Type Parameters

TJob

The job to fire.

TInput

The 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

scheduler IScheduler

The scheduler to schedule on.

input TInput

The payload the firing carries, put on the trigger.

delay TimeSpan

How long from now the job should run.

options OneOffJobOptions

The trigger's identity and the rest of what can be said about one firing.

cancellationToken CancellationToken

The cancellation instruction.

Returns

ValueTask<ScheduledOneOffJob>

Type Parameters

TJob
TInput

Remarks

"Now" is TimeProvider, so a delay is measured against the same clock the scheduling loop will compare it to.