Exemplo n.º 1
0
        private void EhTimer(object sender, EventArgs e)
        {
            _timerCounter++;

            if (_timerCounter == 50)
            {
                Visibility = System.Windows.Visibility.Visible;
            }

            if (_monitor != null)
            {
                if (_monitor.HasReportText)
                {
                    _guiProgressText.Text = _monitor.GetReportText();
                    double frac = _monitor.GetProgressFraction();
                    if (!double.IsNaN(frac))
                    {
                        _guiProgressFraction.Value = Math.Min(1, Math.Max(0, frac));
                    }
                }
                _monitor.SetShouldReportNow();
            }

            if (!_thread.IsAlive)
            {
                _timer.Stop();
                DialogResult = _wasCancelledByUser ? true : false;
            }
        }
Exemplo n.º 2
0
        private void EhTimer(object sender, EventArgs e)
        {
            if (_showUpDownConter == 0)
            {
                if (null != StartDelayExpired)
                {
                    StartDelayExpired();
                }
            }
            _showUpDownConter--;

            if (_monitor != null)
            {
                if (_monitor.HasReportText)
                {
                    _guiProgressText.Text = _monitor.GetReportText();
                    double frac = _monitor.GetProgressFraction();
                    if (!double.IsNaN(frac))
                    {
                        _guiProgressFraction.Value = Math.Min(1, Math.Max(0, frac));
                    }
                }
                _monitor.SetShouldReportNow();
            }

            if (!_thread.IsAlive)
            {
                var timer = (System.Windows.Threading.DispatcherTimer)sender;
                timer.Tick -= EhTimer;
                timer.Stop();
                _timer  = null;
                _thread = null;

                if (ExecutionFinished != null)
                {
                    ExecutionFinished(_wasCancelledByUser ? false : true);
                }
            }
        }