Centeva.Hangfire.HangfireScheduler
1.0.4
Prefix Reserved
dotnet add package Centeva.Hangfire.HangfireScheduler --version 1.0.4
NuGet\Install-Package Centeva.Hangfire.HangfireScheduler -Version 1.0.4
<PackageReference Include="Centeva.Hangfire.HangfireScheduler" Version="1.0.4" />
<PackageVersion Include="Centeva.Hangfire.HangfireScheduler" Version="1.0.4" />
<PackageReference Include="Centeva.Hangfire.HangfireScheduler" />
paket add Centeva.Hangfire.HangfireScheduler --version 1.0.4
#r "nuget: Centeva.Hangfire.HangfireScheduler, 1.0.4"
#:package Centeva.Hangfire.HangfireScheduler@1.0.4
#addin nuget:?package=Centeva.Hangfire.HangfireScheduler&version=1.0.4
#tool nuget:?package=Centeva.Hangfire.HangfireScheduler&version=1.0.4
Centeva.Hangfire.HangfireScheduler
Provides abstractions and base implementations for configuring, scheduling, and managing Hangfire background tasks in .NET 8+ applications. Includes support for dependency injection and customizable task registration for both web and background processing scenarios.
Features
- Base class for defining and registering Hangfire background tasks
- Extension methods for easy DI registration
- Support for custom Hangfire task implementations
- Designed for .NET 8 and modern dependency injection patterns
Installation
Add the NuGet package to your project:
dotnet add package Centeva.Hangfire.HangfireScheduler
Usage
1. Register Services in Dependency Injection
In your application's startup code (e.g., Program.cs or Startup.cs), register the scheduler and your custom tasks as singleton services:
using Centeva.Hangfire.HangfireScheduler;
// Register the HangfireScheduler as a singleton services.AddHangfireScheduler();
// Register your concrete HangfireTasks implementation as a singleton services.AddHangfireTasks<MyHangfireTasks>();
Note: Most applications will register both
HangfireSchedulerand their own implementation ofIHangfireTasksas singletons using the provided extension methods (AddHangfireSchedulerandAddHangfireTasks<T>). If you do not use these extension methods, you must register these services manually in your dependency injection setup.
2. Implement Your Hangfire Tasks
Create a class that inherits from HangfireTasks and implements the required RegisterTasks method:
public class MyHangfireTasks : HangfireTasks
{
public MyHangfireTasks(IServiceProvider sp, IOptions<IHangfireConfig> config) : base(sp, config) { }
public override void RegisterTasks()
{
// Register your recurring or background jobs here
}
}
3. Configuration
Implement the IHangfireConfig interface to provide configuration options for Hangfire, such as enabling/disabling jobs and dashboard access.
public class MyHangfireConfig : IHangfireConfig
{
public bool Enabled { get; init; }
public string[] DashboardAccess { get; init; }
public string ConfigurationKey => "Hangfire";
}
Note: The
ConfigurationKeyproperty in yourIHangfireConfigimplementation determines which section of yourappsettings.jsonis used for Hangfire configuration. By default, it is set to "Hangfire", but you can override this property if your configuration section uses a different name.
Extension Methods
AddHangfireScheduler()
Registers theHangfireScheduleras a singleton.AddHangfireTasks<T>()
Registers your concrete implementation ofHangfireTasksandIHangfireTasksas singletons.
Best Practices
- Always register
HangfireSchedulerand yourIHangfireTasksimplementation as singletons. - Use the provided extension methods for consistent and easy DI setup.
- Use the configuration interface to control job enablement and dashboard access.
Dependencies
- Hangfire.Core
- Microsoft.Extensions.DependencyInjection
- Microsoft.Extensions.Options
- Centeva.PrincipalProvider
License
See LICENSE for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Centeva.PrincipalProvider (>= 1.0.1)
- Hangfire.Core (>= 1.8.22)
- Microsoft.Extensions.Configuration (>= 8.0.0)
- Microsoft.Extensions.DependencyInjection (>= 8.0.1)
- Microsoft.Extensions.Options (>= 8.0.2)
- Newtonsoft.Json (>= 13.0.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.