Hangfire

An easy way to perform background processing in .NET and .NET Core applications. No Windows Service or separate process required.

Backed by persistent storage. Open and free for commercial use.

Latest release   Package downloads   Stars on GitHub

Fire-and-Forget Jobs

Fire-and-forget jobs are executed only once and almost immediately after creation.

var jobId = BackgroundJob.Enqueue(
    () => Console.WriteLine("Fire-and-forget!"));

Delayed Jobs

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

Recurring jobs fire many times on the specified CRON schedule.

RecurringJob.AddOrUpdate(
    "myrecurringjob",
    () => Console.WriteLine("Recurring!"),
    Cron.Daily);

Continuations

Continuations are executed when its parent job has been finished.

BackgroundJob.ContinueJobWith(
    jobId,
    () => Console.WriteLine("Continuation!"));

Batches Pro

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 Continuations Pro

Batch continuation is fired when all background jobs in a parent batch finished.

BatchJob.ContinueBatchWith(batchId, x =>
{
    x.Enqueue(() => Console.WriteLine("Last Job"));
});

Simple

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.

Persistent

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.

Transparent

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.

Reliable

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.

Distributed

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.

Extensible

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.

Efficient

Although the default installation uses SQL Server and polling technique to fetch jobs, you can leverage MSMQ or Redis extensions to reduce the processing latency to minimum.

Self-maintainable

You don't need to perform manual storage clean-up – Hangfire keeps it as clean as possible and removes old records automatically.

Open Source

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!