public void StartTimers() { using (DataClassesDataContext context = m_config.GetNewContext()) { foreach (var u in (context.Urls.Select(x => x))) { UrlTester tester = new UrlTester(u, m_config); Timer t = new Timer(); t.SetIntervalInSeconds(u.Setting.Periode); t.Elapsed += new ElapsedEventHandler(tester.Test); t.Start(); m_urlTimers.Add(u.ID, new UrlTimer { Timer = t, Tester = tester }); LogDebug(string.Format("Timer aangemaakt voor {0}", u)); } } // extra timer om de instellingen bij te werken. m_settingsTimer = new Timer(); m_settingsTimer.SetIntervalInSeconds(10); m_settingsTimer.Elapsed += new ElapsedEventHandler(RefreshUrlCollection); m_settingsTimer.Start(); }
private void AddNewUrlTester(Dictionary<int, UrlTimer> touchedTimers, Url u) { UrlTester tester = new UrlTester(u, m_config); Timer t = new Timer(); t.SetIntervalInSeconds(u.Setting.Periode); t.Elapsed += new ElapsedEventHandler(tester.Test); t.Start(); touchedTimers.Add(u.ID, new UrlTimer { Timer = t, Tester = tester }); LogDebug(string.Format("Timer aangemaakt voor {0}", u)); }