-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
51 lines (43 loc) · 1.65 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using System.Threading;
using Quartz;
using Quartz.Impl;
namespace QuartzImpl
{
class Program
{
static void Main(string[] args)
{
try
{
Common.Logging.LogManager.Adapter = new Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter { Level = Common.Logging.LogLevel.Info };
// Grab the Scheduler instance from the Factory
var scheduler = StdSchedulerFactory.GetDefaultScheduler();
// and start it off
scheduler.Start();
// define the job and tie it to our HelloJob class
var job = JobBuilder.Create<EmailNotificationJob>()
.WithIdentity("job1", "group1")
.Build();
// Trigger the job to run now, and then repeat every 10 seconds
var trigger = TriggerBuilder.Create()
.WithIdentity("trigger1", "group1")
.StartNow()
.WithSimpleSchedule(x => x
.RepeatForever()
.WithIntervalInSeconds(10))
.Build();
// Tell quartz to schedule the job using our trigger
scheduler.ScheduleJob(job, trigger);
Console.WriteLine("Press any key to close the application");
Console.ReadKey();
// and last shut down the scheduler when you are ready to close your program
scheduler.Shutdown();
}
catch (SchedulerException se)
{
Console.WriteLine(se);
}
}
}
}