Quartz. NET Quick Start Lesson 1 (Official Website document translation), quartz.net Quick Start
Quartz. NET Quick Start Lesson 1 (Official Website document translation)
Original article link
Before you use sched, You need to instantiate it (who can guess this ?). When instantiating schedfactory, you need to use ISchedulerFactory.
After you instantiate scheduler. You can start, keep it in wait mode, and disable it. Note: Once scheduler is disabled, it cannot be restarted. Unless you create a new scheduler. If the schededtrigger is not started (Triggers) (the code in the Ijob instance object is not executed), the trigger remains in the waiting state.
1 // construct a scheduler factory 2 ISchedulerFactory schedFact = new StdSchedulerFactory(); 3 4 // get a scheduler 5 IScheduler sched = schedFact.GetScheduler(); 6 sched.Start(); 7 8 // define the job and tie it to our HelloJob class 9 IJobDetail job = JobBuilder.Create<HelloJob>()10 .WithIdentity("myJob", "group1")11 .Build();12 13 // Trigger the job to run now, and then every 40 seconds14 ITrigger trigger = TriggerBuilder.Create()15 .WithIdentity("myTrigger", "group1")16 .StartNow()17 .WithSimpleSchedule(x => x18 .WithIntervalInSeconds(40)19 .RepeatForever())20 .Build();21 22 sched.ScheduleJob(job, trigger);
As shown in the code above, it is easy to make Quartz. NET work. In the next section, we will provide a quick preview of Jobs and Triggers, so that you can better understand the above Code.