Exemple #1
0
        /// <summary>
        /// Initializes data used in the test.
        /// </summary>
        public void SetUp()
        {
            TimeSpan           interval      = TimeSpan.FromSeconds(2);
            int                numberOfTicks = 3;
            DispatcherPriority priority      = DispatcherPriority.Normal;

            // VERY IMPORTANT!!!
            // For the DispatcherTimer to tick when it is not running
            // in a normal WPF application, you must give it a priority
            // higher than 'Background' (which is the default priority).
            // In this demo we give it a priority of 'Normal'.
            _settings = new TickerSettings(interval, numberOfTicks, priority);
        }
        public Ticker(TickerSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            _settings = settings;

            _timer          = new DispatcherTimer(_settings.Priority);
            _timer.Interval = _settings.Interval;
            _timer.Tick    += this.OnTimerTick;
        }