public static void ConfigureJobService(this IServiceCollection services, TimeSpan serviceInterval) { var config = new JobManagerConfig { PeriodInterval = serviceInterval }; services.AddSingleton(config); }
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(); }; }