public void Start() { IBackgroundService backgroundService = (IBackgroundService)container.Resolve(type); backgroundService.RefreshSettings(); //INFO: (erikpo) This check is just to make sure a value was provided for interval and that they can't put in an interval that will take down their server if (backgroundService.Interval.TotalSeconds > 10) { #if DEBUG if (backgroundService.Enabled) { backgroundService.Run(); } #endif isExecuting = false; timer = new Timer( timerCallback, null, backgroundService.Interval, new TimeSpan(0, 0, 0, 0, -1) ); } }
private void timerCallback(object state) { lock (timer) { IBackgroundService backgroundService = (IBackgroundService)container.Resolve(type); backgroundService.RefreshSettings(); if (backgroundService.Enabled) { //TODO: (erikpo) Instead of eating the exception, log it try { backgroundService.Run(); } catch { } } timer.Change(backgroundService.Interval, new TimeSpan(0, 0, 0, 0, -1)); } //TODO: (erikpo) Once background services have a cancel state and timeout interval, check their state and cancel if appropriate }
protected override Task ExecuteAsync(CancellationToken stoppingToken) { Task.Run(async() => { await _service.Run(stoppingToken); }, stoppingToken); return(Task.CompletedTask); }
public void Start() { lock (timer) { if (Status == BackgroundServiceExecutorStatus.Paused || Status == BackgroundServiceExecutorStatus.Stopped) { if (Status == BackgroundServiceExecutorStatus.Stopped) { Status = BackgroundServiceExecutorStatus.Starting; current = (IBackgroundService)container.Resolve(backgroundServiceType); current.Initialize(moduleConfiguration); } Status = BackgroundServiceExecutorStatus.Running; current.Run(moduleConfiguration); timer.Change(interval, new TimeSpan(0, 0, 0, 0, -1)); } } }
public void Start() { IBackgroundService backgroundService = (IBackgroundService)container.Resolve(type); IPlugin plugin = getPlugin(); TimeSpan interval = getInterval(plugin); if (interval.TotalSeconds > 10) { #if DEBUG if (plugin.Enabled) { backgroundService.Run(plugin.Settings); } #endif timer.Change(interval, new TimeSpan(0, 0, 0, 0, -1)); } }
private void timerCallback(object state) { if (!isExecuting) { IBackgroundService backgroundService = (IBackgroundService)container.Resolve(type); backgroundService.RefreshSettings(); if (backgroundService.Enabled) { isExecuting = true; backgroundService.Run(); isExecuting = false; } } //TODO: (erikpo) Once background services have a cancel state and timeout interval, check their state and cancel if appropriate }
private void timerCallback(object state) { lock (timer) { IBackgroundService backgroundService = (IBackgroundService)container.Resolve(type); IPlugin plugin = getPlugin(); TimeSpan interval = getInterval(plugin); if (plugin.Enabled) { try { backgroundService.Run(plugin.Settings); } catch { } } timer.Change(interval, new TimeSpan(0, 0, 0, 0, -1)); } //TODO: (erikpo) Once background services have a cancel state and timeout interval, check their state and cancel if appropriate }