Cette page est affichée en anglais. Une traduction française est en cours.
ScriptsMay 23, 2026·3 min de lecture

Hangfire — Background Job Processing for .NET

A .NET library for running background jobs reliably with persistence, automatic retries, and a built-in monitoring dashboard.

Prêt pour agents

Cet actif peut être lu et installé directement par les agents

TokRepo expose une commande CLI universelle, un contrat d'installation, le metadata JSON, un plan selon l'adaptateur et le contenu raw pour aider les agents à juger l'adaptation, le risque et les prochaines actions.

Native · 98/100Policy : autoriser
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
Hangfire Overview
Commande CLI universelle
npx tokrepo install b8df539c-56c4-11f1-9bc6-00163e2b0d79

Introduction

Hangfire is a .NET library for performing background processing in web and console applications. It persists job state to a database, so jobs survive application restarts. It includes a built-in dashboard for monitoring and managing queues, retries, and scheduled tasks.

What Hangfire Does

  • Runs fire-and-forget jobs that execute once in the background
  • Schedules delayed jobs to run at a future time
  • Manages recurring jobs using CRON expressions
  • Provides continuations that chain jobs together
  • Persists all job state to SQL Server, PostgreSQL, Redis, or other storage

Architecture Overview

Hangfire serializes job method calls and their arguments into a storage backend. A background server polls for pending jobs and executes them in worker threads. Each job transitions through states (Enqueued, Processing, Succeeded, Failed) tracked in the database. The dashboard reads this state data to provide a real-time web UI. Automatic retry with exponential backoff handles transient failures.

Self-Hosting & Configuration

  • Install core and storage packages via NuGet
  • Register services with AddHangfire() and AddHangfireServer() in Program.cs
  • Map the dashboard with app.UseHangfireDashboard() for monitoring
  • Configure worker count, queues, and retry policies in server options
  • Secure the dashboard with authorization filters in production

Key Features

  • Persistent job storage that survives application restarts and deployments
  • Built-in web dashboard with real-time job monitoring
  • Automatic retries with configurable attempt counts and backoff
  • CRON-based recurring job scheduling
  • Batch and continuation job support (Pro edition)

Comparison with Similar Tools

  • Quartz.NET — job scheduler without persistence dashboard; more scheduling power, less monitoring
  • Azure Functions (Timer) — cloud-native serverless scheduling; no self-hosted option
  • Celery (Python) — distributed task queue for Python; different ecosystem, similar concepts
  • Coravel — lightweight .NET task scheduler; simpler, no persistence or dashboard
  • WorkerService — .NET BackgroundService base class; manual implementation, no persistence

FAQ

Q: What databases does Hangfire support? A: The open-source version supports SQL Server. Community packages add PostgreSQL, MySQL, MongoDB, Redis, and SQLite. Some storage providers are maintained by third parties.

Q: Is the dashboard secure by default? A: In development it allows anonymous access. In production, add an IDashboardAuthorizationFilter to restrict access to authenticated administrators.

Q: What is the difference between Hangfire and Hangfire Pro? A: Hangfire (open source, LGPL) covers fire-and-forget, delayed, recurring, and continuation jobs. Hangfire Pro adds batch jobs, Redis storage, and enhanced performance features under a commercial license.

Q: Can Hangfire run in a web farm? A: Yes. Multiple Hangfire servers can process jobs from the same storage. The storage backend handles coordination and ensures each job is processed exactly once.

Sources

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires