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();
			}

		}
Ejemplo n.º 2
0
        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();
            }
        }
Ejemplo n.º 3
0
        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();
                }
            }
        }
        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();
                }
            }
        }