Fixer contains the .Net Core Api support for creating custom tasks with IHostedService interface and uses the NCrontab for the scheduler time pattern.
Add the Fixer latest version nuget package to your .Net Core Api project.
Nuget Address: https://www.nuget.org/packages/Fixer/
Install-Package Fixer -Version 1.0.1
create your task class by implementing ISchedulerTask interface
using Fixer.Core.Scheduler;
using System.Threading;
using System.Threading.Tasks;
namespace FixerSample.Tasks
{
public class FixerSampleTask : ISchedulerTask
{
public string TimePattern => "* * * * *";
public Task ExecuteAsync(CancellationToken cancellationToken)
{
return Task.Run(() =>
{
// your code...
}, cancellationToken);
}
}
}
Add your scheduler and task class to your .Net Core Api project with Dependency Injection
services.AddSingleton<ISchedulerTask, FixerSampleTask>();
services.AddScheduler();
Fixer, uses the open source NCrontab library for scheduler task time pattern
http://www.raboof.com/projects/ncrontab/
Examples of crontab expressions
https://code.google.com/archive/p/ncrontab/wikis/CrontabExamples.wiki