Quartz.NET implementation doesn't jive with tutorials

对着背影说爱祢 提交于 2019-12-02 20:16:50

The documentation is aimed at the 1.0 API. Shiz has now changed :( And yes, they art breaketh.

So .. to help .. check this official migration page out. U might find some love in there.

Colin

I know this isn't the right place. I should edit the original Wiki blah blah blah. I'm trying to do 31 hours of work, in my evenings, by Friday. So here goes.

Lesson 1

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Quartz;
using Quartz.Impl;

namespace QuartzNetTest
{
    class Program
    {
        static void Main(string[] args)
        {
            // construct a scheduler factory
            ISchedulerFactory schedFact = new StdSchedulerFactory();

            // get a scheduler
            IScheduler sched = schedFact.GetScheduler();
            sched.Start();

            // construct job info
            IJobDetail jobDetail = JobBuilder.Create<HelloJob>()
                .WithIdentity("myJob")
                .Build();
            ITrigger trigger = TriggerBuilder.Create()
                .WithIdentity("myTrigger")
                // fire every hour
                .WithSimpleSchedule(x => x.WithIntervalInHours(1).RepeatForever())
                // start on the next even hour
                .StartAt(DateBuilder.FutureDate(1, IntervalUnit.Hour))
                .Build();

            sched.ScheduleJob(jobDetail, trigger);
        }
    }

    class HelloJob : Quartz.IJob
    {
        public void Execute(IJobExecutionContext context)
        {
            Debug.WriteLine("Hello at " + DateTime.Now.ToString());
        }
    }

}

I'm pleased to announce that Quartz.NET's web site has been successfully migrated to GitHub Pages. It should be now easier for community contribute fixes and enhancements.

The tutorial is (finally) updated to include 2.x changes:

http://www.quartz-scheduler.net/documentation/quartz-2.x/tutorial/index.html

Site is written in Markdown and can be updated with pull requests via GitHub:

https://github.com/quartznet/quartznet/tree/gh-pages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!