Quartz.NET usage

Have just tried the Quartz.NET 2.x library! See Quartz.NET – Version Migration Guide.

// Construct a scheduler factory.
var collection = new NameValueCollection
        { "quartz.threadPool.threadCount", "3" }
var schedulerFactory = new StdSchedulerFactory(collection);

// Get a scheduler.
var scheduler = schedulerFactory.GetScheduler();

var jobDetail = JobBuilder.Create()

var trigger = TriggerBuilder.Create()
    .StartAt(DateBuilder.FutureDate(10, IntervalUnit.Second))
    .WithSimpleSchedule(x => x.WithIntervalInSeconds(5).RepeatForever())

scheduler.ScheduleJob(jobDetail, trigger);

// To unschedule job use:

Leave a Reply (Markdown is enabled)

Your email address will not be published.