private void GoHangfireServer() { var o = this.ServiceProvider.GetService <IOptions <HangfireServerConfig> >().Value; var logger = this.ServiceProvider.GetService <ILogger>(); GlobalConfiguration.Configuration.UseSqlServerStorage(Configuration.GetConnectionString(o.ConnectionStringName)); GlobalConfiguration.Configuration.UseActivator(new MyActivator(this)); GlobalJobFilters.Filters.Add(new TraffkJobFilterAttribute(Configuration)); var bo = o.BackgroundOptions ?? new BackgroundJobServerOptions(); var queues = new List <string>(); queues.AddRange(bo.Queues.Where(q => !q.StartsWith("-")).ToArray()); bo.Queues.Where(q => q.StartsWith("-")).ForEach(q => queues.Remove(q.Substring(1))); bo.Queues = queues.ToArray(); OnHangfireServerInitialized(); using (var s = new BackgroundJobServer(bo)) { var timeout = Parse.ParseTimeSpan(Configuration["JobRunner:TimeOut"], TimeSpan.FromSeconds(60)); do { logger.Information("Job Runner Heartbeat."); }while (!ShutdownRequested.WaitOne(timeout)); } }