Exemple #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;
            }
        }
        private void _timer_Elapsed(object sender, EventArgs e)
        {
            if (_monitor != null)
            {
                if (_monitor.HasReportText)
                {
                    this.lblText.Text = _monitor.GetReportText();
                }
                _monitor.SetShouldReportNow();
            }

            if (!_thread.IsAlive)
            {
                _timer.Stop();
                this.DialogResult = wasUserInterrupted ? DialogResult.OK : DialogResult.Cancel;
                this.Close();
            }
        }
Exemple #3
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);
                }
            }
        }