Fire-and-forget jobs are executed only once and almost immediately after creation.
var jobId = BackgroundJob.Enqueue( () => Console.WriteLine("Fire-and-forget!"));
Delayed jobs are executed only once too, but not immediately, after a certain time interval.
var jobId = BackgroundJob.Schedule( () => Console.WriteLine("Delayed!"), TimeSpan.FromDays(7));
Recurring jobs fire many times on the specified CRON schedule.
RecurringJob.AddOrUpdate( "myrecurringjob", () => Console.WriteLine("Recurring!"), Cron.Daily);
Continuations are executed when its parent job has been finished.
BackgroundJob.ContinueJobWith( jobId, () => Console.WriteLine("Continuation!"));
Batch is a group of background jobs that is created atomically and considered as a single entity.
var batchId = BatchJob.StartNew(x =>
{
x.Enqueue(() => Console.WriteLine("Job 1"));
x.Enqueue(() => Console.WriteLine("Job 2"));
});
Batch continuation is fired when all background jobs in a parent batch finished.
BatchJob.ContinueBatchWith(batchId, x =>
{
x.Enqueue(() => Console.WriteLine("Last Job"));
});
Better resiliency of subscription connections when listening empty queues or waiting for locks.
This release contains changes for Hangfire.Core internals to reduce allocations and includes Hangfire.SqlServer fixes to minimize polling queries and prevent silent queue name truncation.
Automatic cleanup of empty queues or queues full of expired jobs so they don't stuck in the Dashboard UI.
Fixed recurring job behavior when they were scheduled to the past in corner cases and added experimental parallel execution for recurring and delayed job schedulers.
Source Link support, signed NuGet package with its assemblies and more secure CI pipeline for the project.
Easy to set up, easy to use. No Windows Service, no Windows Scheduler, no separate applications required.
Background jobs are regular static or instance .NET methods with regular arguments – no base class or interface implementation required.
Background jobs are created in a persistent storage – SQL Server and Redis supported officially, and a lot of other community-driven storages.
You can safely restart your application and use Hangfire with ASP.NET without worrying about application pool recycles.
Built-in web interface allow you to see the whole picture of your background processing, as well as observe the state of each background job.
Out of the box support for popular logging frameworks allows you to catch errors early with zero configuration.
Once a background job was created without any exception, Hangfire takes the responsibility to process it with the at least once semantics.
You are free to throw unhandled exceptions or terminate your application – background jobs will be re-tried automatically.
Background method calls and their arguments are serialized and may overcome the process boundaries.
You can use Hangfire on different machines to get more processing power with no configuration – synchronization is performed automatically.
Job filters allow you to add custom features to the background processing in a way similar to ASP.NET MVC action filters.
Job storage access is fully abstracted and you can implement the support for your favorite storage. Dashboard supports modifications too.
You don't need to perform manual storage clean-up – Hangfire keeps it as clean as possible and removes old records automatically.
Hangfire is open source software and is completely free for commercial use. It is licensed under LGPLv3 license.
Fork the project and make contributions on GitHub!