Do you want to write services the dotnet core way, using the IHostedService interface? Is Quartz server too much for your current need? Then use this extension to run your applicaton with quartz.
Quartz.Extensions.Hosting is available as a Nuget-package. From the Package Manager Console enter:
Install-Package Quartz.Extensions.Hosting
Build a generic host the normal way. Use the HostBuilder class as you normally do when building a console app. Then add in quartz and any scheduler configuration.
var builder = new HostBuilder()
.ConfigureServices((hostContext, services) =>
{
services.AddQuartz(scheduler =>
{
scheduler.ScheduleJob(
JobBuilder
.Create(typeof(HelloJob))
.Build(),
TriggerBuilder
.Create()
.WithSimpleSchedule(s => s
.WithIntervalInSeconds(5)
.RepeatForever())
.Build());
});
});
In Startup.cs, use the extension method in ConfigureServices. Order is not important with registration.
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
services.AddQuartz(scheduler =>
{
scheduler.ScheduleJob(
JobBuilder
.Create(typeof(HelloJob))
.Build(),
TriggerBuilder
.Create()
.WithSimpleSchedule(s => s
.WithIntervalInSeconds(5)
.RepeatForever())
.Build());
});
}