Esempio n. 1
0
        /// <summary>
        /// The RunProg.
        /// </summary>
        private void RunProg()
        {
            _programIsInProgress = true;
            Task.Run(
                () =>
            {
                while (EvaluateProgramPosition() && _programIsInProgress)
                {
                    if (ExecutionPaused && !_pauseComplete && _programIsInProgress)
                    {
                        Application.Current.Dispatcher.Invoke(() => _playbackService.RunningStepPaused());
                        _pauseComplete = true;
                    }

                    if (!ExecutionPaused && _programIsInProgress)
                    {
                        if (!_pauseComplete)
                        {
                            Thread.Sleep(TimeSpan.FromSeconds(new Random().Next(2, 5) + new Random().NextDouble()));
                        }

                        _pauseComplete = false;
                        if (!ExecutionPaused && _programIsInProgress)
                        {
                            Application.Current.Dispatcher.Invoke(() => _playbackService.AdvanceStep());
                        }
                    }
                }

                if (_programIsInProgress)
                {
                    Application.Current.Dispatcher.Invoke(() => _playbackService.AdvanceStep());
                    _programIsInProgress = false;
                }
            });
        }