static void Main() { // log4net.Config.XmlConfigurator.Configure();00000000 logger = NLog.LogManager.GetCurrentClassLogger(); logger.Info("Worker Host process has been started"); unityContainer = UnityConfig.Register(); UnityConfig.ConfigureDefaults(unityContainer); var storage = new SqlServerStorage("HangfireStorageDbContext"); var options = new BackgroundJobServerOptions() { WorkerCount = 10 }; UnityJobActivator unityJobActivator = new UnityJobActivator(unityContainer); GlobalConfiguration.Configuration.UseActivator(unityJobActivator); JobActivator.Current = unityJobActivator; GlobalJobFilters.Filters.Add(new ChildContainerPerJobFilterAttribute(unityJobActivator)); var server = new BackgroundJobServer(options, storage); server.Start(); Thread.Sleep(300000); server.Stop(); }
public static void Stop() { if (_serverA != null) { _serverA.Stop(); _serverA.Dispose(); } if (_serverB != null) { _serverB.Stop(); _serverB.Dispose(); } }
protected void Application_End() { _server.Stop(); }