Table of Contents

Class CalendarIntervalTriggerImpl

Namespace
Quartz.Impl.Triggers
Assembly
Quartz.dll

A concrete ITrigger that is used to fire a IJobDetail based upon repeating calendar time intervals.

[Serializable]
public class CalendarIntervalTriggerImpl : TriggerBase, IOperableTrigger, IMutableTrigger, IEquatable<TriggerBase>, ICalendarIntervalTrigger, ITrigger
Inheritance
CalendarIntervalTriggerImpl
Implements
Inherited Members

Remarks

The trigger will fire every N (see RepeatInterval) units of calendar time (see RepeatIntervalUnit) as specified in the trigger's definition. This trigger can achieve schedules that are not possible with ISimpleTrigger (e.g because months are not a fixed number of seconds) or ICronTrigger (e.g. because "every 5 months" is not an even divisor of 12).

If you use an interval unit of Month then care should be taken when setting a StartTimeUtc value that is on a day near the end of the month. For example, if you choose a start time that occurs on January 31st, and have a trigger with unit Month and interval 1, then the next fire time will be February 28th, and the next time after that will be March 28th - and essentially each subsequent firing will occur on the 28th of the month, even if a 31st day exists. If you want a trigger that always fires on the last day of the month - regardless of the number of days in the month, you should use ICronTrigger.

Constructors

CalendarIntervalTriggerImpl(TimeProvider?)

Create a ICalendarIntervalTrigger with no settings.

public CalendarIntervalTriggerImpl(TimeProvider? timeProvider = null)

Parameters

timeProvider TimeProvider

Time provider instance to use, defaults to System

Remarks

Everything this trigger needs is a settable property, so the object-initializer form new CalendarIntervalTriggerImpl { Key = ..., RepeatIntervalUnit = ..., RepeatInterval = ... } replaces the constructor overloads that used to spell out each combination.

Properties

EndTimeUtc

Get the time at which the ICalendarIntervalTrigger should quit repeating.

public override DateTimeOffset? EndTimeUtc { get; set; }

Property Value

DateTimeOffset?

FinalFireTimeUtc

Returns the final time at which the ICalendarIntervalTrigger will fire, if there is no end time set, null will be returned.

public override DateTimeOffset? FinalFireTimeUtc { get; }

Property Value

DateTimeOffset?

Remarks

Note that the return time may be in the past.

HasMillisecondPrecision

Tells whether this Trigger instance can handle events in millisecond precision.

protected override bool HasMillisecondPrecision { get; }

Property Value

bool

MayFireAgain

Determines whether or not the ICalendarIntervalTrigger will occur again.

public override bool MayFireAgain { get; }

Property Value

bool

MisfireInstruction

What the scheduler does when this trigger misses a firing.

public CalendarIntervalTriggerMisfireInstruction MisfireInstruction { get; }

Property Value

CalendarIntervalTriggerMisfireInstruction
See Also

NextFireTimeUtc

Returns the next time at which the ITrigger is scheduled to fire. If the trigger will not fire again, null will be returned. Note that the time returned can possibly be in the past, if the time that was computed for the trigger to next fire has already arrived, but the scheduler has not yet been able to fire the trigger (which would likely be due to lack of resources e.g. threads).

public override DateTimeOffset? NextFireTimeUtc { get; set; }

Property Value

DateTimeOffset?

Remarks

The value returned is not guaranteed to be valid until after the ITrigger has been added to the scheduler.

PreserveHourOfDayAcrossDaylightSavings

If intervals are a day or greater, this property (set to true) will cause the firing of the trigger to always occur at the same time of day, (the time of day of the startTime) regardless of daylight saving time transitions. Default value is false.

public bool PreserveHourOfDayAcrossDaylightSavings { get; set; }

Property Value

bool

Remarks

For example, without the property set, your trigger may have a start time of 9:00 am on March 1st, and a repeat interval of 2 days. But after the daylight saving transition occurs, the trigger may start firing at 8:00 am every other day.

If however, the time of day does not exist on a given day to fire (e.g. 2:00 am in the United States on the days of daylight saving transition), the trigger will go ahead and fire one hour off on that day, and then resume the normal hour on other days. If you wish for the trigger to never fire at the "wrong" hour, then you should set the property skipDayIfHourDoesNotExist.

See Also

PreviousFireTimeUtc

Returns the previous time at which the ICalendarIntervalTrigger fired. If the trigger has not yet fired, null will be returned.

public override DateTimeOffset? PreviousFireTimeUtc { get; set; }

Property Value

DateTimeOffset?

RepeatInterval

Get the time interval that will be added to the ICalendarIntervalTrigger's fire time (in the set repeat interval unit) in order to calculate the time of the next trigger repeat.

public int RepeatInterval { get; set; }

Property Value

int

RepeatIntervalUnit

Get or set the interval unit - the time unit on with the interval applies.

public IntervalUnit RepeatIntervalUnit { get; set; }

Property Value

IntervalUnit

SkipDayIfHourDoesNotExist

If intervals are a day or greater, and preserveHourOfDayAcrossDaylightSavings property is set to true, and the hour of the day does not exist on a given day for which the trigger would fire, the day will be skipped and the trigger advanced a second interval if this property is set to true. Defaults to false.

public bool SkipDayIfHourDoesNotExist { get; set; }

Property Value

bool

Remarks

CAUTION! If you enable this property, and your hour of day happens to be that of daylight savings transition (e.g. 2:00 am in the United States) and the trigger's interval would have had the trigger fire on that day, then you may actually completely miss a firing on the day of transition if that hour of day does not exist on that day! In such a case the next fire time of the trigger will be computed as double (if the interval is 2 days, then a span of 4 days between firings will occur).

See Also

StartTimeUtc

Get the time at which the CalendarIntervalTriggerImpl should occur.

public override DateTimeOffset StartTimeUtc { get; set; }

Property Value

DateTimeOffset

TimeZone

Gets the time zone within which time calculations related to this trigger will be performed.

public TimeZoneInfo TimeZone { get; set; }

Property Value

TimeZoneInfo

Remarks

If null, the system default TimeZone will be used.

TimesTriggered

Get the number of times the ICalendarIntervalTrigger has already fired.

public int TimesTriggered { get; set; }

Property Value

int

Methods

ComputeFirstFireTimeUtc(ICalendar?)

This method should not be used by the Quartz client.

public override DateTimeOffset? ComputeFirstFireTimeUtc(ICalendar? calendar)

Parameters

calendar ICalendar

Returns

DateTimeOffset?

The first time at which the ITrigger will be fired by the scheduler, which is also the same value NextFireTimeUtc will return (until after the first firing of the ITrigger).

Remarks

Called by the scheduler at the time a ITrigger is first added to the scheduler, in order to have the ITrigger compute its first fire time, based on any associated calendar.

After this method has been called, NextFireTimeUtc should return a valid answer.

GetFireTimeAfter(DateTimeOffset?)

Returns the next time at which the ICalendarIntervalTrigger will fire, after the given time. If the trigger will not fire after the given time, null will be returned.

public override DateTimeOffset? GetFireTimeAfter(DateTimeOffset? afterTime)

Parameters

afterTime DateTimeOffset?

Returns

DateTimeOffset?

Remarks

A fire time that lands exactly on EndTimeUtc is one the trigger fires: the end time is the last instant at which a trigger may fire.

GetScheduleBuilder()

Get a IScheduleBuilder that is configured to produce a schedule identical to this trigger's schedule.

public override IScheduleBuilder GetScheduleBuilder()

Returns

IScheduleBuilder

Triggered(ICalendar?)

This method should not be used by the Quartz client.

Called when the IScheduler has decided to 'fire' the trigger (Execute the associated IJob), in order to give the ITrigger a chance to update itself for its next triggering (if any).

public override void Triggered(ICalendar? calendar)

Parameters

calendar ICalendar
See Also

UpdateAfterMisfire(ICalendar?)

Updates the ICalendarIntervalTrigger's state based on the MisfireInstruction.XXX that was selected when the ICalendarIntervalTrigger was created.

public override void UpdateAfterMisfire(ICalendar? calendar)

Parameters

calendar ICalendar

Remarks

If the misfire instruction is set to SmartPolicy, then the following scheme will be used:

UpdateWithNewCalendar(ICalendar, TimeSpan)

This method should not be used by the Quartz client.

The implementation should update the ITrigger's state based on the given new version of the associated ICalendar (the state should be updated so that it's next fire time is appropriate given the Calendar's new settings).

public override void UpdateWithNewCalendar(ICalendar calendar, TimeSpan misfireThreshold)

Parameters

calendar ICalendar
misfireThreshold TimeSpan

Validate()

Validates whether the properties of the IJobDetail are valid for submission into a IScheduler.

public override void Validate()

ValidateMisfireInstruction(int)

Validates the misfire instruction.

protected override bool ValidateMisfireInstruction(int misfireInstruction)

Parameters

misfireInstruction int

The misfire instruction.

Returns

bool