The project is the extensions of Quartz for .net core project, it benefits you from DependencyInjection.
NuGet feed: https://www.nuget.org/packages/Quartz.NetCore.DependencyInjection/
Package | NuGet Stable | NuGet Pre-release | Downloads |
---|---|---|---|
Quartz.NetCore.DependencyInjection |
Quartz.NetCore.DependencyInjection is a NuGet library that you can add into your project that will benefit you from DependencyInjection for Quartz Job.
please see the example:samples
First of all, add this namespace:
using Quartz.NetCore.DependencyInjection;
In ConfigureServices
, you need register jobs to container:
services.ConfigQuartzJob<DemoJob>(
jobBuilder => jobBuilder.WithIdentity("DemoJobKey").Build(),
//Run job every 10 seconds
triggerBuild => triggerBuild.WithIdentity("DemoJobTriggerKey")
.StartAt(DateTime.Now.AddSeconds(10))
.WithSimpleSchedule(
ssb => ssb.WithInterval(TimeSpan.FromSeconds(10))
.RepeatForever())
.Build());
If you are in asp.net core 3.1 or later, you can just call:
services.AutoStartQuartzJob()
else you need get QuartzLifeTimeManager
instance from container, then call then Start
method. Note: You should get instance at root service provider