Exemple #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();
        }
Exemple #2
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();
        }
 public ChildContainerPerJobFilterAttribute(UnityJobActivator unityJobActivator)
 {
     UnityJobActivator = unityJobActivator;
 }
 public ChildContainerPerJobFilterAttribute(UnityJobActivator unityJobActivator)
 {
     UnityJobActivator = unityJobActivator;
 }