Class JobKey
- Namespace
- Quartz
- Assembly
- Quartz.dll
Uniquely identifies a IJobDetail.
[Serializable]
public sealed class JobKey : Key<JobKey>, IComparable<Key<JobKey>>, IComparable, IEquatable<Key<JobKey>>, IComparable<JobKey>, IEquatable<JobKey>, IParsable<JobKey>
- Inheritance
-
JobKey
- 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 group 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
JobKey(string)
Names a job in the default group.
public JobKey(string name)
Parameters
namestringThe name, unique within the group.
JobKey(string, string)
Names a job in a group.
public JobKey(string name, string group)
Parameters
Methods
CompareTo(JobKey?)
Orders keys by group and then name, ordinally, with DefaultGroup sorting before every other group.
public int CompareTo(JobKey? other)
Parameters
otherJobKey
Returns
Remarks
Declared here as well as on the base so that Default finds a
comparison of this type: the inherited one is over Key<JobKey>, which the
default comparer does not recognise, and without this List<JobKey>.Sort(),
OrderBy(k => k) and SortedSet<T> throw at runtime while compiling fine.
Equals(JobKey?)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(JobKey? other)
Parameters
otherJobKeyAn object to compare with this object.
Returns
Equals(object?)
Indicates whether the current object is equal to another object of the same type.
public override bool Equals(object? obj)
Parameters
objobject
Returns
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.job" parses to group DEFAULT, name my.job.
public static JobKey Parse(string s)
Parameters
sstringThe composed key string.
Returns
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
sis null.- FormatException
scontains no '.'.
TryParse(string?, out JobKey)
Parses the <group>.<name> form ToString() produces —
"DEFAULT.my.job" parses to group DEFAULT, name my.job.
public static bool TryParse(string? s, out JobKey result)
Parameters
Returns
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
sis null.- FormatException
scontains no '.'.