Building an Asp.Net Core Windows Service Task Scheduler
Write the Service

As we have installed all of our dependencies, we are ready to create our service. Add a new class with the name BackupService and inherit the same from IHostedService , which is part of Microsoft.Extensions.Hosting namespace.

IHostedService has two methods in it as follows, so we should implement them in our service class:

IHostedService

StartAsync

The StartAsync method can be implemented as follows:

StartAsync

As you can see in the first line of the above code, we are getting the scheduler of Quartz. Let’s create a method and return a scheduler:

GetScheduler

The next step is to build a service provider so that we can inject our dependencies using Constructor Dependency Injection. By default Quartz is not doing this, so we have to build the configuration our own.

GetConfiguredServiceProvider

As you can see, we have configured the services for DailyJob , WeeklyJob , MonthlyJob , and HelperService . We will be creating these Classes and Interfaces very soon.

Once we get the Service Provider, we can pass this to our Custom Job Factory, which we will be implementing soon. Now, we can start the scheduler and schedule our jobs, please make sure that you are using different Identity names for both Triggers and Jobs. The samples are given below:

Jobs And Triggers

StopAsync

The StopAsync method can be implemented as follows:
['Sibeesh Venu']
['Quartz', 'Task Scheduler', 'Aspnetcore', 'Azure', 'Windows Services']