Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

AnderssonPeter/Hangfire.Console.Extensions

Repository files navigation

Hangfire.Console.Extensions

NuGet version

Features

  • Makes it easier to use Hangfire.Console with .net core dependency injection

Setup

In .NET Core's Startup.cs:

public void ConfigureServices(IServiceCollection services)
{
 services.AddHangfire((serviceProvider, configuration) => configuration
 .UseConsole()
 .SetDataCompatibilityLevel(CompatibilityLevel.Version_180)
 .UseSimpleAssemblyNameTypeSerializer()
 .UseRecommendedSerializerSettings()
 .UseMemoryStorage());
 services.AddHangfireConsoleExtensions();
 services.AddHangfireServer();
}

Starting a job

To start a job you can use the IJobManager, it will automatically check if you are currently inside a job, if that is the case it will mark the started job as a Continuation.

Log

Instead of logging using the extension method on PerformContext you can now just use the ILogging and it will get logged to both normal logging facilities and Hangfire.Console.

Progressbar

To create a progress bar you can use IProgressBarFactory.

IJobCancellationToken

Just take the IJobCancellationToken as a constructor parameter to get a hold of the cancellation token.

Schedule jobs

Contains a extension method for AddOrUpdateManuallyTriggered if you have a job that should only be run manually.

Hangfire.Console.Extensions.Serilog

NuGet version

Usage with Serilog.Settings.Configuration

Add WithHangfireContext to Enrich and add Hangfire as a WriteTo target Example:

"Serilog": {
 "Enrich": [ "WithHangfireContext" ],
 "WriteTo": [
 {
 "Name": "Hangfire",
 "Args": {
 "restrictedToMinimumLevel": "Information"
 }
 }
 ]
}

About

Makes it easier to use Hangfire.Console with .net core dependency injection

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 8

Languages

AltStyle によって変換されたページ (->オリジナル) /