Class RecurrenceTriggerImpl
A concrete ITrigger that fires based on an iCalendar RFC 5545 recurrence rule (RRULE).
public class RecurrenceTriggerImpl : TriggerBase, IOperableTrigger, IMutableTrigger, IEquatable<TriggerBase>, IRecurrenceTrigger, ITrigger
- Inheritance
-
RecurrenceTriggerImpl
- Implements
- Inherited Members
Remarks
This trigger supports complex scheduling patterns that cannot be expressed with CRON expressions, such as "every 2nd Monday of the month", "every other week on Monday, Wednesday, and Friday", or "the last weekday of March each year".
Constructors
RecurrenceTriggerImpl()
Create a RecurrenceTriggerImpl with no settings.
public RecurrenceTriggerImpl()
RecurrenceTriggerImpl(string, string, string, TimeProvider?)
Create a RecurrenceTriggerImpl with the given name, group, and RRULE.
public RecurrenceTriggerImpl(string name, string group, string recurrenceRule, TimeProvider? timeProvider = null)
Parameters
namestringgroupstringrecurrenceRulestringtimeProviderTimeProvider
Properties
EndTimeUtc
Gets and sets the date/time on which the trigger must stop firing. This defines the final boundary for trigger firings 舒 the trigger will not fire after this date and time. If this value is null, no end time boundary is assumed, and the trigger can continue indefinitely.
public override DateTimeOffset? EndTimeUtc { get; set; }
Property Value
Remarks
The end time is inclusive, for every trigger type: it is the last instant at which the trigger may fire, so a fire time exactly equal to it is one the trigger fires, and the first instant after it is where the schedule stops.
FinalFireTimeUtc
Returns the last UTC time at which the ITrigger will fire, if the Trigger will repeat indefinitely, null will be returned.
Note that the return time *may* be in the past.
public override DateTimeOffset? FinalFireTimeUtc { get; }
Property Value
HasMillisecondPrecision
Whether this trigger's fire times are meaningful to the millisecond. A trigger that says no has its start time rounded down to the second.
protected override bool HasMillisecondPrecision { get; }
Property Value
Remarks
This is how a trigger describes its own schedule to TriggerBase, not something a caller reads: nothing outside the trigger acted on it.
MayFireAgain
Used by the IScheduler to determine whether or not it is possible for this ITrigger to fire again.
If the returned value is false then the IScheduler may remove the ITrigger from the IJobStore.
public override bool MayFireAgain { get; }
Property Value
MisfireInstruction
What the scheduler does when this trigger misses a firing.
public RecurrenceTriggerMisfireInstruction MisfireInstruction { get; }
Property Value
- 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
Remarks
The value returned is not guaranteed to be valid until after the ITrigger has been added to the scheduler.
The setter should not be used by client code. The scheduler advances this as it fires the trigger; assigning it yourself corrupts the schedule.
PreviousFireTimeUtc
The previous time at which the ITrigger fired. If the trigger has not yet fired, null will be returned.
public override DateTimeOffset? PreviousFireTimeUtc { get; set; }
Property Value
Remarks
The setter should not be used by client code. The scheduler records this as it fires the trigger; assigning it yourself corrupts the schedule.
RecurrenceRule
The RFC 5545 RRULE string.
public string RecurrenceRule { get; set; }
Property Value
StartTimeUtc
The time at which the trigger's scheduling should start. May or may not be the first actual fire time of the trigger, depending upon the type of trigger and the settings of the other properties of the trigger. However the first actual first time will not be before this date.
public override DateTimeOffset StartTimeUtc { get; set; }
Property Value
Remarks
Setting a value in the past may cause a new trigger to compute a first fire time that is in the past, which may cause an immediate misfire of the trigger.
TimeZone
The time zone for recurrence calculations.
public TimeZoneInfo TimeZone { get; set; }
Property Value
TimesTriggered
The number of times this trigger has fired.
public int TimesTriggered { get; set; }
Property Value
Methods
ComputeFirstFireTimeUtc(ICalendar?)
This method should not be used by the Quartz client.
public override DateTimeOffset? ComputeFirstFireTimeUtc(ICalendar? calendar)
Parameters
calendarICalendar
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 ITrigger 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
afterTimeDateTimeOffset?
Returns
GetScheduleBuilder()
Get a IScheduleBuilder that is configured to produce a schedule identical to this trigger's schedule.
public override IScheduleBuilder GetScheduleBuilder()
Returns
Triggered(ICalendar?)
This method should not be used by the Quartz client.
public override void Triggered(ICalendar? calendar)
Parameters
calendarICalendar
Remarks
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).
- See Also
UpdateAfterMisfire(ICalendar?)
This method should not be used by the Quartz client.
To be implemented by the concrete classes that extend this class.
The implementation should update the ITrigger's state according to the misfire instruction the ITrigger was built with, read as MisfireInstructionCode.
public override void UpdateAfterMisfire(ICalendar? calendar)
Parameters
calendarICalendar
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
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
misfireInstructionintThe misfire instruction.