Class SimpleTriggerImpl
A concrete ITrigger that is used to fire a IJobDetail at a given moment in time, and optionally repeated at a specified interval.
[Serializable]
public class SimpleTriggerImpl : TriggerBase, IOperableTrigger, IMutableTrigger, IEquatable<TriggerBase>, ISimpleTrigger, ITrigger
- Inheritance
-
SimpleTriggerImpl
- Implements
- Inherited Members
Constructors
SimpleTriggerImpl(string, string, string, string, DateTimeOffset, DateTimeOffset?, int, TimeSpan, TimeProvider?)
Create a SimpleTriggerImpl that will occur at the given time, fire the identified IJob and repeat at the given interval the given number of times, or until the given end time.
public SimpleTriggerImpl(string name, string group, string jobName, string jobGroup, DateTimeOffset startTimeUtc, DateTimeOffset? endTimeUtc, int repeatCount, TimeSpan repeatInterval, TimeProvider? timeProvider = null)
Parameters
namestringThe name.
groupstringThe group.
jobNamestringName of the job.
jobGroupstringThe job group.
startTimeUtcDateTimeOffsetA DateTimeOffset set to the time for the ITrigger to fire.
endTimeUtcDateTimeOffset?A DateTimeOffset set to the time for the ITrigger to quit repeat firing.
repeatCountintThe number of times for the ITrigger to repeat firing, use RepeatIndefinitely for unlimited times.
repeatIntervalTimeSpanThe time span to pause between the repeat firing.
timeProviderTimeProviderTime provider instance to use, defaults to System
Exceptions
- ArgumentNullException
name,group,jobNameorjobGroupare null.
SimpleTriggerImpl(TimeProvider?)
Create a SimpleTriggerImpl with no settings.
public SimpleTriggerImpl(TimeProvider? timeProvider = null)
Parameters
timeProviderTimeProviderTime provider instance to use, defaults to System
Remarks
Everything this trigger needs is a settable property, so the object-initializer form
new SimpleTriggerImpl { Key = ..., StartTimeUtc = ..., RepeatCount = ... } replaces
the constructor overloads that used to spell out each combination.
Fields
RepeatIndefinitely
Used to indicate the 'repeat count' of the trigger is indefinite. Or in other words, the trigger should repeat continually until the trigger's ending timestamp.
public const int RepeatIndefinitely = -1
Field Value
Properties
FinalFireTimeUtc
Returns the final UTC time at which the ISimpleTrigger will fire, if repeatCount is RepeatIndefinitely, null will be returned.
Note that the return time may be in the past.
public override DateTimeOffset? FinalFireTimeUtc { get; }
Property Value
HasMillisecondPrecision
Tells whether this Trigger instance can handle events in millisecond precision.
protected override bool HasMillisecondPrecision { get; }
Property Value
MayFireAgain
Determines whether or not the ISimpleTrigger will occur again.
public override bool MayFireAgain { get; }
Property Value
MisfireInstruction
What the scheduler does when this trigger misses a firing.
public SimpleTriggerMisfireInstruction MisfireInstruction { get; }
Property Value
- See Also
NextFireTimeUtc
Returns the next time at which the ISimpleTrigger will fire. If the trigger will not fire again, null will be returned. The value returned is not guaranteed to be valid until after the ITrigger has been added to the scheduler.
public override DateTimeOffset? NextFireTimeUtc { get; set; }
Property Value
PreviousFireTimeUtc
Returns the previous time at which the ISimpleTrigger fired. If the trigger has not yet fired, null will be returned.
public override DateTimeOffset? PreviousFireTimeUtc { get; set; }
Property Value
RepeatCount
Get or set the number of times the SimpleTriggerImpl should repeat, after which it will be automatically deleted.
public int RepeatCount { get; set; }
Property Value
- See Also
RepeatInterval
Get or set the time interval at which the ISimpleTrigger should repeat.
public TimeSpan RepeatInterval { get; set; }
Property Value
TimesTriggered
Get or set the number of times the ISimpleTrigger has already fired.
public int TimesTriggered { get; set; }
Property Value
Methods
ComputeFirstFireTimeUtc(ICalendar?)
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.
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).
ComputeNumberOfTimesFiredBetween(DateTimeOffset, DateTimeOffset)
Computes the number of times fired between the two UTC date times.
public int ComputeNumberOfTimesFiredBetween(DateTimeOffset startTimeUtc, DateTimeOffset endTimeUtc)
Parameters
startTimeUtcDateTimeOffsetThe UTC start date and time.
endTimeUtcDateTimeOffsetThe UTC end date and time.
Returns
GetFireTimeAfter(DateTimeOffset?)
Returns the next UTC time at which the ISimpleTrigger will fire, after the given UTC time. If the trigger will not fire after the given time, null will be returned.
public override DateTimeOffset? GetFireTimeAfter(DateTimeOffset? afterTimeUtc)
Parameters
afterTimeUtcDateTimeOffset?
Returns
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.
GetFireTimeBefore(DateTimeOffset)
Returns the last UTC time at which the ISimpleTrigger will fire, before the given time. If the trigger will not fire before the given time, null will be returned.
public DateTimeOffset? GetFireTimeBefore(DateTimeOffset endUtc)
Parameters
endUtcDateTimeOffset
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?)
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
calendarICalendar
- See Also
UpdateAfterMisfire(ICalendar?)
Updates the ISimpleTrigger's state based on the MisfireInstruction value that was selected when the ISimpleTrigger was created.
public override void UpdateAfterMisfire(ICalendar? calendar)
Parameters
calendarICalendar
Remarks
If MisfireSmartPolicyEnabled is set to true,
then the following scheme will be used:
- If the Repeat Count is 0, then the instruction will be interpreted as FireNow.
- If the Repeat Count is RepeatIndefinitely, then the instruction will be interpreted as NextWithRemainingCount. WARNING: using NowWithRemainingCount with a trigger that has a non-null end-time may cause the trigger to never fire again if the end-time arrived during the misfire time span.
- If the Repeat Count is > 0, then the instruction will be interpreted as NowWithExistingCount.
UpdateWithNewCalendar(ICalendar, TimeSpan)
Updates the instance with new calendar.
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.