Hangfire
Hangfire copied to clipboard
IServiceCollection.AddHangfireServer example configuration
Hi all,
I'm using Hangfire for quite some time. Is it possible to provide the new configuration for the extension method IServiceCollection AddHanfireServer to pass additional processes and a BackgroundJobServerOptions instance to this new method?
The previous method (IApplicationBuilder AddHangfireServer) is now obsolete and now it requires a NotNull instance of JobStorage on ConfigureServices method.
@odinserj
Any class registered in the DI as IBackgroundProcess is automatically added as an additional service. See CreateBackgroundJobServerHostedService method
@akarboush
What??
What I meant, just use the AddHanfireServer
method that takes optionsAction and no JobStorage as parameter
public static IServiceCollection AddHangfireServer(
[NotNull] this IServiceCollection services,
[NotNull] Action<IServiceProvider, BackgroundJobServerOptions> optionsAction)
{ ...... }
then add any additional services by registering them as IBackgroundProcess
in the DI Container. You could create an extension method for it if you want to
Oh. I see. You mean something like this instead of the commented?
This seems to work.. :)