Skip to main content
v1.0.0Open source · .NET 8 · .NET 10

Background jobs that work the night shift.

Fire-and-forget, delayed, recurring and continuation jobs for .NET, stored in a database you already run. Jobs survive restarts and deploys, failures are retried for you, and a built-in dashboard shows what is happening. No Windows Service or Task Scheduler needed. It is a remastered fork of Hangfire that calls your jobs through source-generated code instead of reflection. See how they compare.

dotnet add package Masterly.NightShift
/nightshift/jobs
0 processing0 succeeded0 failed1 scheduled
  1. #1042EmailService.SendWelcome(42)Enqueuedqueue: default
  2. #1043OrderService.ChargeAsync(1001)Enqueuedqueue: default
  3. #1044EmailService.SendReceipt(1001)Awaitingafter #1043
  4. #daily-reportReportService.BuildDaily()Scheduledrecurring · tomorrow at 06:00
4 job types
fire-and-forget, delayed, recurring, continuations
5 packages
one shared version
0 reflection
job methods are called through generated code
SQL Server
storage in the box; others plug in
Create

One line to run it later

A job is a call to one of your methods. Its arguments are stored, so the job runs even if the process that created it has gone away.

Runs once, as soon as a worker is free. If it throws, it is retried automatically. Learn more

app.MapPost("/users/{id:int}/welcome", (int id, IBackgroundJobClient jobs) =>
{
string? jobId = jobs.Enqueue<EmailService>(x => x.SendWelcome(id));
return Results.Accepted(value: new { jobId });
});
Run

Everything a job needs in production

Start with one job. Add retries, limits, schedules and monitoring when you need them, with attributes and configuration rather than new infrastructure.

Retries that back off on their own

A job that throws is retried up to ten times with growing, jittered delays. Add retry-later, in-process retries and circuit breakers when a dependency is down.

Read the guide
  1. 1Attempt 1Failed: HttpRequestException
  2. 2Retry 1Scheduled in 34 s
  3. 3Attempt 2Failed: timeout
  4. 4Retry 2Scheduled in 1 min 2 s
  5. 5Attempt 3Succeeded

Concurrency control

One at a time, throttling, rate limits and duplicate prevention, across every server.

Read the guide

Timeouts and run windows

Job timeouts, deadlines, run windows and blackouts, and how long finished jobs are kept.

Read the guide

A dashboard for operators

Live monitoring, search, insights, failure clusters, lineage, a wallboard and a "why isn't it running?" diagnosis.

Read the guide

No reflection

A source generator emits direct calls to your job methods, so they are not invoked through reflection.

Read the guide

Schedules in plain English

Cron.FromText turns a phrase into a CRON expression, and Cron.Describe explains one back.

Read the guide
English phrases and the CRON expressions they become
Cron.FromText(...)CRON
"every 15 minutes"*/15 * * * *
"weekdays at 9"0 9 * * 1-5
"every 10 minutes from 9am to 5pm on weekdays"*/10 9-17 * * 1-5
"last day of month at 23:00"0 23 L * *

Drain mode

Stop starting new jobs for the whole system, a queue or one server, then deploy.

Read the guide

Alerts and webhooks

Failures and missed deadlines sent to Slack, Microsoft Teams, Discord or any URL.

Read the guide

OpenTelemetry

Traces and metrics for every job through UseTelemetry(), cheap when nobody listens.

Read the guide

Health checks and metrics

ASP.NET Core health checks, plus /health and Prometheus /metrics endpoints for probes and scrapers.

Read the guide

Your first job, running in five minutes.

The quick start goes from an empty web app to a job you can watch in the dashboard.