Table of Contents

Class TriggerKey

Namespace
Quartz
Assembly
Quartz.dll

Uniquely identifies a ITrigger.

[Serializable]
public sealed class TriggerKey : Key<TriggerKey>, IComparable<Key<TriggerKey>>, IComparable, IEquatable<Key<TriggerKey>>, IComparable<TriggerKey>, IEquatable<TriggerKey>, IParsable<TriggerKey>
Inheritance
TriggerKey
Implements
Inherited Members

Remarks

Keys are composed of both a name and group, and the name must be unique within the group. If only a name is specified then the default group name will be used.

Quartz provides a builder-style API for constructing scheduling-related entities via a Domain-Specific Language (DSL). The DSL can best be utilized through the usage of static imports of the methods on the classes TriggerBuilder, JobBuilder, DateBuilder, JobKey, TriggerKey and the various IScheduleBuilder implementations.

Client code can then use the DSL to write code such as this:

IJobDetail job = JobBuilder.Create<MyJob>()
    .WithIdentity("myJob")
    .Build();
ITrigger trigger = TriggerBuilder.Create()
    .WithIdentity("myTrigger", "myTriggerGroup")
    .WithSimpleSchedule(x => x
        .WithInterval(TimeSpan.FromHours(1))
        .RepeatForever())
    .StartAt(DateTimeOffset.UtcNow.AddMinutes(10))
    .Build();
scheduler.scheduleJob(job, trigger);

Constructors

TriggerKey(string)

Names a trigger in the default group.

public TriggerKey(string name)

Parameters

name string

The name, unique within the group.

TriggerKey(string, string)

Names a trigger in a group.

public TriggerKey(string name, string group)

Parameters

name string

The name, unique within the group.

group string

The group.

Methods

CompareTo(TriggerKey?)

Orders keys by group and then name, ordinally, with DefaultGroup sorting before every other group.

public int CompareTo(TriggerKey? other)

Parameters

other TriggerKey

Returns

int

Remarks

Declared here as well as on the base so that Default finds a comparison of this type: the inherited one is over Key<TriggerKey>, which the default comparer does not recognise, and without this List<TriggerKey>.Sort(), OrderBy(k => k) and SortedSet<T> throw at runtime while compiling fine.

Equals(TriggerKey?)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(TriggerKey? other)

Parameters

other TriggerKey

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Indicates whether the current object is equal to another object of the same type.

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.

Parse(string)

Parses the <group>.<name> form ToString() produces — "DEFAULT.my.trigger" parses to group DEFAULT, name my.trigger.

public static TriggerKey Parse(string s)

Parameters

s string

The composed key string.

Returns

TriggerKey

Remarks

The string splits at the first '.', the exact inverse of how ToString() composes it. A group containing '.' is the ambiguous case: such a key parses at the first dot, which is not the key it printed from.

Exceptions

ArgumentNullException

s is null.

FormatException

s contains no '.'.

TryParse(string?, out TriggerKey)

Parses the <group>.<name> form ToString() produces — "DEFAULT.my.trigger" parses to group DEFAULT, name my.trigger.

public static bool TryParse(string? s, out TriggerKey result)

Parameters

s string

The composed key string.

result TriggerKey

Returns

bool

Remarks

The string splits at the first '.', the exact inverse of how ToString() composes it. A group containing '.' is the ambiguous case: such a key parses at the first dot, which is not the key it printed from.

Exceptions

ArgumentNullException

s is null.

FormatException

s contains no '.'.

See Also