public void RunningWatcherKeepsOnlyOnePollingThread() { ConfigurationChangeWatcher.SetDefaultPollDelayInMilliseconds(50); TestConfigurationChangeWatcher watcher = new TestConfigurationChangeWatcher(); try { watcher.ConfigurationChanged += new ConfigurationChangedEventHandler(OnConfigurationChanged); for (int i = 0; i < 20; i++) { watcher.StopWatching(); watcher.StartWatching(); } // ramp up Thread.Sleep(50); watcher.DoNotification(); // wait for notification Thread.Sleep(150); Assert.AreEqual(1, notifications); } finally { watcher.StopWatching(); ConfigurationChangeWatcher.ResetDefaultPollDelay(); } }
public void RunningWatcherKeepsOnlyOnePollingThread() { using (TestConfigurationChangeWatcher watcher = new TestConfigurationChangeWatcher(50)) { try { watcher.ConfigurationChanged += new ConfigurationChangedEventHandler(OnConfigurationChanged); for (int i = 0; i < 20; i++) { watcher.StopWatching(); watcher.StartWatching(); } // ramp up Thread.Sleep(50); watcher.DoNotification(); // wait for notification Thread.Sleep(150); Assert.AreEqual(1, notifications); } finally { watcher.StopWatching(); } } }