Table of Contents

Class SimpleTriggerImpl

Namespace
Quartz.Impl.Triggers
Assembly
Quartz.dll

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

name string

The name.

group string

The group.

jobName string

Name of the job.

jobGroup string

The job group.

startTimeUtc DateTimeOffset

A DateTimeOffset set to the time for the ITrigger to fire.

endTimeUtc DateTimeOffset?

A DateTimeOffset set to the time for the ITrigger to quit repeat firing.

repeatCount int

The number of times for the ITrigger to repeat firing, use RepeatIndefinitely for unlimited times.

repeatInterval TimeSpan

The time span to pause between the repeat firing.

timeProvider TimeProvider

Time provider instance to use, defaults to System

Exceptions

ArgumentNullException

name, group, jobName or jobGroup are null.

SimpleTriggerImpl(TimeProvider?)

Create a SimpleTriggerImpl with no settings.

public SimpleTriggerImpl(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 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

int

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

DateTimeOffset?

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 ISimpleTrigger will occur again.

public override bool MayFireAgain { get; }

Property Value

bool

MisfireInstruction

What the scheduler does when this trigger misses a firing.

public SimpleTriggerMisfireInstruction MisfireInstruction { get; }

Property Value

SimpleTriggerMisfireInstruction
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

DateTimeOffset?

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

DateTimeOffset?

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

int
See Also

RepeatInterval

Get or set the time interval at which the ISimpleTrigger should repeat.

public TimeSpan RepeatInterval { get; set; }

Property Value

TimeSpan

TimesTriggered

Get or set the number of times the ISimpleTrigger has already fired.

public int TimesTriggered { get; set; }

Property Value

int

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

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).

ComputeNumberOfTimesFiredBetween(DateTimeOffset, DateTimeOffset)

Computes the number of times fired between the two UTC date times.

public int ComputeNumberOfTimesFiredBetween(DateTimeOffset startTimeUtc, DateTimeOffset endTimeUtc)

Parameters

startTimeUtc DateTimeOffset

The UTC start date and time.

endTimeUtc DateTimeOffset

The UTC end date and time.

Returns

int

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

afterTimeUtc 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.

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

endUtc DateTimeOffset

Returns

DateTimeOffset?

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?)

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 ISimpleTrigger's state based on the MisfireInstruction value that was selected when the ISimpleTrigger was created.

public override void UpdateAfterMisfire(ICalendar? calendar)

Parameters

calendar ICalendar

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

calendar ICalendar

The calendar.

misfireThreshold TimeSpan

The misfire threshold.

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

See Also