- Makes it easier to use
Hangfire.Console
with .net core dependency injection
In .NET Core's Startup.cs:
public void ConfigureServices(IServiceCollection services)
{
services.AddHangfireConsoleExtensions();
}
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.
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.
To create a progress bar you can use IProgressBarFactory
.
Just take the IJobCancellationToken
as a constructor parameter to get a hold of the cancellation token.
Add WithHangfireContext
to Enrich
and add Hangfire
as a WriteTo target
Example:
"Serilog": {
"Enrich": [ "WithHangfireContext" ],
"WriteTo": [
{
"Name": "Hangfire",
"Args": {
"restrictedToMinimumLevel": "Information"
}
}
]
}