private void ButtonStartClick(object sender, EventArgs e)
        {
            long interval;

            // Read interval from form
            if (!long.TryParse(TextBoxInterval.Text, out interval))
            {
                return;
            }

            // Set timer interval
            _microTimer.Interval = interval;

            // Ignore event if late by half the interval
            _microTimer.IgnoreEventIfLateBy = interval / 2;

            // Start timer
            _microTimer.Start();
        }
Exemplo n.º 2
0
        private void StartTimer()
        {
            dispatcherTimer.MicroTimerElapsed += (x, y) =>
            {
                if (_timerState == TimerState.Run)
                {
                    if (!_stopWatch.IsRunning)
                    {
                        _stopWatch.Reset();
                        _stopWatch.Start();
                    }

                    if (_stopWatch.ElapsedMilliseconds > 100)
                    {
                        _stopWatch.Stop();

                        if (_curTimeMs > 0)
                        {
                            _curTimeMs -= 100;
                            UpdateWindowLabelTimers();
                        }
                        if (_curTimeMs <= 0)
                        {
                            _curTimeMs = 0;
                            _mainDisp.BeginInvoke(new Action(() =>
                            {
                                StopAndHide();
                            }));
                        }
                        else
                        {
                            _stopWatch.Reset();
                            _stopWatch.Start();
                        }
                    }
                }
            };
            dispatcherTimer.Interval = (long)(10000);//millis
            dispatcherTimer.Start();
        }
Exemplo n.º 3
0
 private void btnReverse_Click(object sender, EventArgs e)
 {
     playbackActive  = true;
     playbackForward = false;
     fastTimer.Start();
 }