Documentation¶

Pluralsight Course

From the 10.000-feet view the library consist of three main components: client, storage and server. Here is a small diagram that describes the main processes in Hangfire:

Requirements¶

Hangfire is not tied to the specific .NET application type. You can use it in ASP.NET , non-ASP.NET web applications, in console applications or . Here are the requirements:

  • .NET Framework 4.5
  • Persistent storage (listed below)
  • Newtonsoft.Json library ≥ 5.0.1

You can create any kind of background jobs using Hangfire: (to offload the method invocation), delayed (to perform the call after some time) and (to perform methods hourly, daily and so on).

There is also more easy way to create background jobs – the class that allows you to use static methods to perform the creation task.

The control is returned to a caller just after Hangfire serializes the given information and saves it to the storage.

Job Storage¶

Hangfire keeps background jobs and other information that relates to the processing inside a persistent storage. Persistence helps background jobs to survive on application restarts, server reboots, etc. This is the main distinction between performing background jobs using CLR’s Thread Pool and Hangfire. Different storage backends are supported:

  • SQL Azure, SQL Server 2008 R2 (and later of any edition, including Express)

  • SQL Server storage can be empowered with MSMQ or RabbitMQ to lower the processing latency.

All you need is to create an instance of the BackgroundJobServer class and start the processing:

Hangfire uses reliable fetching algorithm for each storage backend, so you can start the processing inside a web application without a risk of losing background jobs on application restarts, process termination and so on.

Table of Contents¶

原文: