예제 #1
0
        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();
        }
예제 #2
0
        public static void Stop()
        {
            if (_serverA != null)
            {
                _serverA.Stop();
                _serverA.Dispose();
            }

            if (_serverB != null)
            {
                _serverB.Stop();
                _serverB.Dispose();
            }
        }
예제 #3
0
        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();
        }
예제 #4
0
 protected void Application_End()
 {
     _server.Stop();
 }