skynyrd
2/16/2017 - 1:14 PM

Quartz .NET Ex

Quartz .NET Ex

// Quarz, C#

using System;
using Quartz;
using Quartz.Impl;


namespace Dummy
{
    class Program
    {
        static void Main(string[] args)
        {
            var schedulerFactory = new StdSchedulerFactory();
 
            var scheduler = schedulerFactory.GetScheduler();
            scheduler.Start();
 
            var job = JobBuilder.Create <SimpleJob>()
                        .WithIdentity("job1", "group1")
                        .Build();
 
            var trigger = TriggerBuilder.Create()
                .WithIdentity("trigger1", "group1")
                .WithSimpleSchedule(x => x.WithIntervalInSeconds(1).RepeatForever())
                .Build();
 
            scheduler.ScheduleJob(job, trigger);
 
        }
    }

    public class SimpleJob : IJob
    {
        void IJob.Execute(IJobExecutionContext context)
        {
            Console.WriteLine("Hello, Job executed");
        }
    }
}