Table of Contents

Interface ITriggerListener

Namespace
Quartz
Assembly
Quartz.dll

The interface to be implemented by classes that want to be informed when a ITrigger fires. In general, applications that use a IScheduler will not have use for this mechanism.

public interface ITriggerListener

Remarks

Every callback leads with the ITrigger it is about, and every callback is told which scheduler is calling it: a listener reaches the scheduler it serves through its execution context, or as a second argument when there is no execution. Only TriggerMisfired(ITrigger, IScheduler, CancellationToken) is of the second kind — a misfire is noticed rather than executed, so it has no context to carry one.

Every member has a default implementation, so an implementation only has to write the notifications it cares about. Name defaults to the implementing type's name.

Properties

Name

The name this listener is registered and removed under.

string Name { get; }

Property Value

string

Remarks

Defaults to the implementing type's name, which is the right answer whenever a scheduler has at most one listener of a given type. Override it when several instances of one type are registered with the same scheduler, because the later registration would otherwise replace the earlier one.

Methods

TriggerComplete(ITrigger, IJobExecutionContext, SchedulerInstruction, CancellationToken)

Called by the IScheduler when a ITrigger has fired, it's associated IJobDetail has been executed, and it's Triggered(ICalendar?) method has been called.

ValueTask TriggerComplete(ITrigger trigger, IJobExecutionContext context, SchedulerInstruction triggerInstructionCode, CancellationToken cancellationToken = default)

Parameters

trigger ITrigger

The ITrigger that was fired.

context IJobExecutionContext

The IJobExecutionContext that was passed to the IJob'sExecute(IJobExecutionContext, CancellationToken) method.

triggerInstructionCode SchedulerInstruction

The result of the call on the ITrigger'sTriggered(ICalendar?) method.

cancellationToken CancellationToken

The cancellation instruction.

Returns

ValueTask

Remarks

The default implementation does nothing.

TriggerFired(ITrigger, IJobExecutionContext, CancellationToken)

Called by the IScheduler when a ITrigger has fired, and it's associated IJobDetail is about to be executed.

It is called before the VetoJobExecution(ITrigger, IJobExecutionContext, CancellationToken) method of this interface.

ValueTask TriggerFired(ITrigger trigger, IJobExecutionContext context, CancellationToken cancellationToken = default)

Parameters

trigger ITrigger

The ITrigger that has fired.

context IJobExecutionContext

The IJobExecutionContext that will be passed to the IJob'sExecute(IJobExecutionContext, CancellationToken) method.

cancellationToken CancellationToken

The cancellation instruction.

Returns

ValueTask

Remarks

The default implementation does nothing.

TriggerMisfired(ITrigger, IScheduler, CancellationToken)

Called by the IScheduler when a ITrigger has misfired.

Consideration should be given to how much time is spent in this method, as it will affect all triggers that are misfiring. If you have lots of triggers misfiring at once, it could be an issue it this method does a lot.

ValueTask TriggerMisfired(ITrigger trigger, IScheduler scheduler, CancellationToken cancellationToken = default)

Parameters

trigger ITrigger

The ITrigger that has misfired.

scheduler IScheduler

The scheduler raising the notification.

cancellationToken CancellationToken

The cancellation instruction.

Returns

ValueTask

Remarks

The scheduler is passed because a misfire is noticed outside any execution, so there is no IJobExecutionContext here to reach it through. It comes after the trigger, as the context does on every other notification in this interface.

The default implementation does nothing.

VetoJobExecution(ITrigger, IJobExecutionContext, CancellationToken)

Called by the IScheduler when a ITrigger has fired, and it's associated IJobDetail is about to be executed.

It is called after the TriggerFired(ITrigger, IJobExecutionContext, CancellationToken) method of this interface. If the implementation vetoes the execution (via returning true), the job's execute method will not be called.

ValueTask<bool> VetoJobExecution(ITrigger trigger, IJobExecutionContext context, CancellationToken cancellationToken = default)

Parameters

trigger ITrigger

The ITrigger that has fired.

context IJobExecutionContext

The IJobExecutionContext that will be passed to the IJob'sExecute(IJobExecutionContext, CancellationToken) method.

cancellationToken CancellationToken

The cancellation instruction.

Returns

ValueTask<bool>

Returns true if job execution should be vetoed, false otherwise.

Remarks

The default implementation vetoes nothing.

See Also