src/Quartz/README.md
Quartz.NET is a full-featured, open source job scheduling system that can be used from the smallest apps to large scale enterprise systems.
dotnet add package Quartz
To add JSON serialization for persistent job stores, also add Quartz.Serialization.SystemTextJson (or Quartz.Serialization.Json).
using Quartz;
using Quartz.Impl;
// grab the scheduler instance from the factory and start it
StdSchedulerFactory factory = new StdSchedulerFactory();
IScheduler scheduler = await factory.GetScheduler();
await scheduler.Start();
// define the job and tie it to our HelloJob class
IJobDetail job = JobBuilder.Create<HelloJob>()
.WithIdentity("job1", "group1")
.Build();
// trigger the job to run now, and then repeat every 10 seconds
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("trigger1", "group1")
.StartNow()
.WithSimpleSchedule(x => x
.WithIntervalInSeconds(10)
.RepeatForever())
.Build();
await scheduler.ScheduleJob(job, trigger);
public class HelloJob : IJob
{
public async Task Execute(IJobExecutionContext context)
{
await Console.Out.WriteLineAsync("Greetings from HelloJob!");
}
}
Tip: Quartz.NET comes with sane defaults — you only need explicit configuration when you want to change them.
📖 Full documentation: https://www.quartz-scheduler.net/documentation/quartz-3.x/