public HangfireBackgroundService(ILifetimeScope rootScope, HangfireConfig hangfireConfig, StartupHandler startupHandler, JobStorageFactory jobStorageFactory)
 {
     this.rootScope         = rootScope;
     this.hangfireConfig    = hangfireConfig;
     this.startupHandler    = startupHandler;
     this.jobStorageFactory = jobStorageFactory;
 }
示例#2
0
        public static IServiceCollection AddHangfire(this IServiceCollection serviceDescriptors, Action <IGlobalConfiguration, HangfireConfig> configureDelegate = null)
        {
            serviceDescriptors.AddHostedService <HangfireBackgroundService>();
            serviceDescriptors.AddTransient <IRecurringJobFactory, RecurringJobFactory>();

            var hangfireConfig = new HangfireConfig();

            Globals.DefaultConfiguration.Bind(hangfireConfig);
            serviceDescriptors.AddSingleton(hangfireConfig);

            serviceDescriptors.AddHangfire(configuration: cfg => configureDelegate?.Invoke(cfg, hangfireConfig));
            serviceDescriptors.AddTransient <JobStorageFactory>();
            serviceDescriptors.AddTransient <IRecurringJobManager, MIFCoreRecurringJobManager>();

            return(serviceDescriptors);
        }