Esta página se muestra en inglés. Una traducción al español está en curso.
ScriptsMay 23, 2026·3 min de lectura

Hangfire — Background Job Processing for .NET

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

Listo para agents

Este activo puede ser leído e instalado directamente por agents

TokRepo expone un comando CLI universal, contrato de instalación, metadata JSON, plan según adaptador y contenido raw para que los agents evalúen compatibilidad, riesgo y próximos pasos.

Native · 98/100Política: permitir
Superficie agent
Cualquier agent MCP/CLI
Tipo
Skill
Instalación
Single
Confianza
Confianza: Established
Entrada
Hangfire Overview
Comando CLI universal
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

Discusión

Inicia sesión para unirte a la discusión.
Aún no hay comentarios. Sé el primero en compartir tus ideas.

Activos relacionados