danzuep / PeriodicScheduler

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PeriodicScheduler

Code Size

Scheduling is easily done with Cron in json:

{
  "CronScheduling": {
    "Name": "Periodic Scheduler",
    "Expression": "0 5 ? * *",
    "AutoStart": true
  }
}

Scheduling with PeriodicScheduler is as easy as:

while (!cancellationToken.IsCancellationRequested)
{
    try
    {
        await _taskScheduler.WaitForScheduledStartAsync(cancellationToken);
        await ExecuteScopedProcessAsync(cancellationToken);
    }
    catch (OperationCanceledException)
    {
        _logger.LogTrace("Periodic timer cancelled");
    }
    catch (Exception ex)
    {
        _logger.LogError(ex, "Periodic task failed, waiting for scheduled retry");
    }
}

About


Languages

Language:C# 89.3%Language:Dockerfile 9.0%Language:PowerShell 1.7%