Ejemplo n.º 1
0
        private IEnumerable <IDisposable> GetHangfireServers()
        {
            GlobalConfiguration.Configuration
            .UseMemoryStorage()
            .UseSimpleAssemblyNameTypeSerializer()
            .UseRecommendedSerializerSettings()
            .UseManagementPages(typeof(Startup).Assembly);

            var options = new BackgroundJobServerOptions();
            var queues  = new List <string>();

            queues.Add("default");
            queues.AddRange(JobsHelper.GetAllQueues());

            options.Queues = queues.Distinct().ToArray();
            yield return(new BackgroundJobServer(options));
        }
Ejemplo n.º 2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddHangfire((configuration) =>
            {
                configuration
                .UseMemoryStorage()
                .UseSimpleAssemblyNameTypeSerializer()
                .UseRecommendedSerializerSettings()
                .UseManagementPages(typeof(Startup).Assembly);
            });

            services.AddHangfireServer((options) => {
                var queues = new List <string>();
                queues.Add("default");
                queues.AddRange(JobsHelper.GetAllQueues());

                options.Queues = queues.Distinct().ToArray();
            });

            services.AddRazorPages();
        }