Exemplo n.º 1
0
        public static void ConfigureJobService(this IServiceCollection services, TimeSpan serviceInterval)
        {
            var config = new JobManagerConfig {
                PeriodInterval = serviceInterval
            };

            services.AddSingleton(config);
        }
Exemplo n.º 2
0
        public JobManager(IServiceProvider container,
                          IRepository repository,
                          IPowerManager powerManager,
                          IConnectivity connectivity,
                          JobManagerConfig config = null) : base(container, repository, powerManager, connectivity)
        {
            config              = config ?? new JobManagerConfig();
            this.timer          = new Timer(config.PeriodInterval.TotalMilliseconds);
            this.timer.Elapsed += async(sender, args) =>
            {
                this.timer.Stop();
                await this.RunAll(CancellationToken.None);

                this.timer.Start();
            };
        }