Skip to content

StartAsync

Schedules all registered recurring job metadata values. For each RecurringJob, the method calls Hangfire's recurring job manager with the job name, execution method, and cron expression.

Application code normally should not call this method directly. Register recurring jobs first, then register JobSchedulerStartup as a hosted service and let the .NET host call it during application startup.

Usage

csharp
using AlmightyShogun.Hangfire.Utils;
using Microsoft.Extensions.DependencyInjection;

builder.Services
    .RegisterRecurringJobs(typeof(Program).Assembly)
    .AddHostedService<JobSchedulerStartup>();

Parameters

cancellationToken: CancellationToken
Host cancellation token provided during startup.

Returns

A completed task after discovered recurring jobs have been scheduled.

Type signature

csharp
public Task StartAsync(CancellationToken cancellationToken);

Uses

All packages are released under the MIT License.