Mehedi.Hangfire.Extensions 1.0.14

dotnet add package Mehedi.Hangfire.Extensions --version 1.0.14
                    
NuGet\Install-Package Mehedi.Hangfire.Extensions -Version 1.0.14
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Mehedi.Hangfire.Extensions" Version="1.0.14" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Mehedi.Hangfire.Extensions" Version="1.0.14" />
                    
Directory.Packages.props
<PackageReference Include="Mehedi.Hangfire.Extensions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Mehedi.Hangfire.Extensions --version 1.0.14
                    
#r "nuget: Mehedi.Hangfire.Extensions, 1.0.14"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Mehedi.Hangfire.Extensions@1.0.14
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Mehedi.Hangfire.Extensions&version=1.0.14
                    
Install as a Cake Addin
#tool nuget:?package=Mehedi.Hangfire.Extensions&version=1.0.14
                    
Install as a Cake Tool

Nuget Nuget

Mehedi.Hangfire.Extensions

Useful extension methods to be able to use Hangfire to create background jobs.

Give a Star! ⭐

If you like this project, learn something or you are using it in your applications, please give it a star. Thanks!

Installation

Install the package via NuGet first:

Install-Package Mehedi.Hangfire.Extensions

Or via the .NET Core command line interface:

dotnet add package Mehedi.Hangfire.Extensions

Either commands, from Package Manager Console or .NET Core CLI, will download and install package and all required dependencies.

Getting Started with ASP.NET Core API

Step 1

Create ASP.NET Core API project. Then install the following dependencies with the following commands.

dotnet add package Hangfire.AspNetCore
dotnet add package Mehedi.Hangfire.Extensions

Step 2

To store messages we'll need databases. For an example if we want to store messages (http requests etc.) inside postgres, add the following package.

dotnet add package Hangfire.PostgreSql

Step 3

Update appsettings.json with postgres connection string.

  "ConnectionStrings": {
    "HangfireConnection": "Host=localhost;Port=5432;Database=hangfire;Username=postgres;Password=postgres;"
  },

Step 4

Inside Program.cs file write the following code snippets.

builder.Services.AddHangfire(config =>
{
    config.UsePostgreSqlStorage(c => c.UseNpgsqlConnection(builder.Configuration.GetConnectionString("HangfireConnection")));
    config.UseMediatR(); // Custom extension built on 
});
builder.Services.AddHangfireServer();

and

app.UseHangfireDashboard();

Step 5

Add PlaceOrder class as the following code snippet

public class PlaceOrder : IRequest
{
    public Guid OrderId { get; set; }
}

Step 6

Inside Controller simply enque requests like the following code snippets as an example.

    [HttpPost("/sales/orders/{orderId:Guid}")]
    public IActionResult Action([FromRoute] Guid orderId)
    {
        _mediator.Enqueue("Place Order", new PlaceOrder
        {
            OrderId = orderId
        });

        return Ok($"Job created");
    }

If you face any more complexity, then just follow the example project to getting started. Example

Dependencies

  • net8.0
  • Hangfire.Core (>= 1.8.12)
  • MediatR (>= 12.2.0)

References

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.14 123 2/5/2025
1.0.13 120 1/23/2025
1.0.12 145 5/20/2024
1.0.11 137 5/20/2024
1.0.10 121 5/15/2024
1.0.9 122 5/15/2024
1.0.8 136 5/15/2024
1.0.7 126 5/15/2024
1.0.6 126 5/15/2024
1.0.5 133 5/15/2024
1.0.4 138 5/15/2024
1.0.3 134 5/15/2024
1.0.2 189 5/15/2024
1.0.1 140 5/15/2024
1.0.0 130 5/14/2024