Class TriggerBuilder
- Namespace
- Quartz
- Assembly
- Quartz.dll
TriggerBuilder is used to instantiate ITriggers.
public static class TriggerBuilder
- Inheritance
-
TriggerBuilder
- Inherited Members
Remarks
The builder will always try to keep itself in a valid state, with reasonable defaults set for calling build() at any point. For instance if you do not invoke WithSchedule(..) method, a default schedule of firing once immediately will be used. As another example, if you do not invoked WithIdentity(..) a trigger name will be generated for you.
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);
Methods
Create(TimeProvider?)
Create a new TriggerBuilder with which to define a specification for a Trigger.
public static TriggerBuilder<IJob> Create(TimeProvider? timeProvider = null)
Parameters
timeProviderTimeProviderTime provider instance to use, defaults to System
Returns
- TriggerBuilder<IJob>
the new TriggerBuilder
Create<TJob>(TimeProvider?)
Create a new TriggerBuilder for a trigger that fires a known job type.
public static TriggerBuilder<TJob> Create<TJob>(TimeProvider? timeProvider = null) where TJob : IJob
Parameters
timeProviderTimeProviderTime provider instance to use, defaults to System
Returns
- TriggerBuilder<TJob>
the new TriggerBuilder
Type Parameters
TJob
Remarks
The job type stays with the builder, so the trigger's job data can name the job's properties rather than spell their keys.