Skip to main content
Version: 1.0.1

Job Scheduling

Provides scheduled job operations.

Schedule Configurations

Schedule config for scheduling jobs.

PropertiesDescription
CronExpressionCron expression of job.
TimeZoneInfoTime zone information of job.
CronFormatCron format enum.

Usage

Create your job class with inherit MilvaCronJobService. Override ExecuteAsync method. This is the method by which the work is done. Write the job you want to schedule in this method.

public class MyCronJob : MilvaCronJobService
{
public MyCronJob(IScheduleConfig scheduleConfig) : base(scheduleConfig)
{
}

public override async Task ExecuteAsync(CancellationToken cancellationToken) => Console.WriteLine("Executed!");
}

Register the required services to service collection.


services.AddMilvaCronJob<MyCronJob>(c =>
{
c.TimeZoneInfo = TimeZoneInfo.Local;
c.CronExpression = @"* * * * * *"; // Every second
c.CronFormat = CronFormat.IncludeSeconds;
});