public RefreshDataModule( TimeSpan refreshInterval, ISensorDataProvider sensorDataProvider, SensorDataCache cache, CancellationToken cancelRefreshSensorsToken) { this.RefreshInterval = refreshInterval; this.Cache = cache; this.SensorDataProvider = sensorDataProvider; this.Report = new UpdateSensorDataReport(); RefreshSensorsData(); this.RefreshTimer = new Timer { AutoReset = true, Interval = this.RefreshInterval.TotalMilliseconds }; this.RefreshTimer.Elapsed += RefreshTimer_Elapsed; this.RefreshTimer.Start(); cancelRefreshSensorsToken.Register( () => { this.RefreshTimer.Stop(); this.RefreshTimer.Elapsed -= RefreshTimer_Elapsed; this.Report.LogState(updateStopped: true); } ); }
public SensorService( TimeSpan refreshInterval, IReadOnlyCollection <int> sensorIds, ISensorDataProvider sensorDataProvider, RequestReport requestReport, CancellationToken cancelRefreshSensorsToken) { var cache = new SensorDataCache(sensorIds); _refreshDataModule = new RefreshDataModule( refreshInterval, sensorDataProvider, cache, cancelRefreshSensorsToken ); this.Cache = cache; this.Report = requestReport; }