https://github.com/soenneker/soenneker.hangfire.util
A general-purpose, reusable utility class for managing Hangfire background jobs
https://github.com/soenneker/soenneker.hangfire.util
background csharp dotnet hangfire hangfireutil queue util
Last synced: about 2 months ago
JSON representation
A general-purpose, reusable utility class for managing Hangfire background jobs
- Host: GitHub
- URL: https://github.com/soenneker/soenneker.hangfire.util
- Owner: soenneker
- License: mit
- Created: 2025-03-23T00:10:19.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2026-03-20T12:11:22.000Z (3 months ago)
- Last Synced: 2026-03-20T18:42:26.540Z (3 months ago)
- Topics: background, csharp, dotnet, hangfire, hangfireutil, queue, util
- Language: C#
- Homepage: https://soenneker.com
- Size: 532 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
[](https://www.nuget.org/packages/soenneker.hangfire.util/)
[](https://github.com/soenneker/soenneker.hangfire.util/actions/workflows/publish-package.yml)
[](https://www.nuget.org/packages/soenneker.hangfire.util/)
[](https://github.com/soenneker/soenneker.hangfire.util/actions/workflows/codeql.yml)
#  Soenneker.Hangfire.Util
### A general-purpose, reusable utility class for managing Hangfire background jobs
## Installation
```
dotnet add package Soenneker.Hangfire.Util
```
```csharp
builder.Services.Configure(options =>
{
options.BatchSize = 200;
options.NotifyOnUnhandledFailedJobs = true;
options.ShouldDeleteFailedJob = job =>
{
// Example: Only delete jobs older than 7 days
return job.FailedAt < DateTime.UtcNow.AddDays(-7);
};
options.ShouldDeleteSucceededJob = job =>
{
// Example: Delete all successful jobs older than 1 day
return job.SucceededAt < DateTime.UtcNow.AddDays(-1);
};
});
// Register the HangfireUtil service
builder.Services.AddHangfireUtilAsSingleton();
RecurringJob.AddOrUpdate($"{nameof(IHangfireUtil.DeleteFailedJobs)}", c => c.DeleteFailedJobs(), "0 0 * * *");
```