Quartz.NET implementation doesn't jive with tutorials

后端 未结 3 1767
感情败类
感情败类 2021-02-02 08:56

I attempted to implement a very simple Quartz.net implementation using this tutorial

using Quartz;
using Quartz.Impl;

// construct a scheduler factory
ISchedule         


        
3条回答
  •  伪装坚强ぢ
    2021-02-02 09:18

    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()
                    .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());
            }
        }
    
    }
    

提交回复
热议问题