Table of Contents

Interface IJob<TInput>

Namespace
Quartz
Assembly
Quartz.dll

A job that declares the type of the input it is scheduled with, so the payload arrives as a parameter instead of being dug out of a JobDataMap by key.

public interface IJob<TInput> : IJob

Type Parameters

TInput

The type of the payload this job is scheduled with.

Inherited Members

Remarks

The input is put on the job or, more usually, on the trigger — UsingInput on either builder — and the scheduler stores it as a string under JobInput. The trigger's input wins over the job's, exactly as any other job data does.

public sealed record SendEmail(string To, string Subject);

public sealed class SendEmailJob : IJob<SendEmail> { public ValueTask Execute(IJobExecutionContext context, SendEmail input, CancellationToken cancellationToken = default) { // input.To, input.Subject return default; } }

TInput exists at compile time in exactly one place: the default implementation of Execute(IJobExecutionContext, CancellationToken) below. Everything that runs a job — the job factory, JobRunShell, the listeners — sees an IJob, and dispatching to a typed job from there would mean closing a generic method over a runtime type, which no trimmed or natively compiled application can do. Being a default interface method rather than a base class also leaves a job free to derive from whatever it likes.

A job whose input is missing fails the firing with a SchedulerException naming the key, rather than running with a default payload.

Methods

Execute(IJobExecutionContext, TInput, CancellationToken)

Called by the IScheduler when a ITrigger fires that is associated with this job, with the input the job was scheduled with.

ValueTask Execute(IJobExecutionContext context, TInput input, CancellationToken cancellationToken = default)

Parameters

context IJobExecutionContext

The execution context.

input TInput

The payload this firing was scheduled with.

cancellationToken CancellationToken

Signalled when this execution is interrupted. The same token as CancellationToken, for the reason Execute(IJobExecutionContext, CancellationToken) gives.

Returns

ValueTask

See Also