/// <summary> /// Add Elsa Hangfire Services for background processing and Hangfire services. /// </summary> /// <remarks> /// Use only if Hangfire is not already registered in DI. /// </remarks> /// <param name="timersOptions">The TimersOptions being configured</param> /// <param name="configure">Configure Hangfire settings</param> public static void UseHangfire(this TimersOptions timersOptions, Action <IGlobalConfiguration> configure) { timersOptions.UseHangfire(); // Add Hangfire services. timersOptions.Services.AddHangfire(configure); // Add the processing server as IHostedService timersOptions.Services.AddHangfireServer(); }
/// <summary> /// Add Elsa Hangfire Services for background processing and Hangfire services. /// </summary> /// <remarks> /// Use only if Hangfire is not already registered in DI. /// </remarks> /// <param name="timersOptions">The TimersOptions being configured</param> /// <param name="configure">Configure Hangfire settings</param> /// <param name="configureJobServer">Configure Hangfire job server settings</param> public static void UseHangfire(this TimersOptions timersOptions, Action <IGlobalConfiguration> configure, Action <IServiceProvider, BackgroundJobServerOptions>?configureJobServer = default) { timersOptions.UseHangfire(); var services = timersOptions.Services; // Add Hangfire services. services.AddHangfire(configure); // Add the processing server as IHostedService if (configureJobServer != null) { services.AddHangfireServer(configureJobServer); } else { services.AddHangfireServer(); } }