Пример #1
0
 private void UpdateUi()
 {
     GridValsVm.UpdateData(Star2Grid.CurValuesAsP2Vs());
     GridDeltasVm.UpdateData(Star2Grid.CurDeltasAsP2Vs());
     AbsDelta   = A2dUt.flattenRowMajor(Star2Grid.Stars).Sum(st => st.AbsDelta);
     NoiseField = A2dUt.flattenRowMajor(Star2Grid.Stars).Sum(st => st.NoiseField);
     OnPropertyChanged("Generation");
     OnPropertyChanged("ElapsedTime");
 }
Пример #2
0
        private async void DoStart()
        {
            _cancellationTokenSource = new CancellationTokenSource();
            _isRunning = true;
            CommandManager.InvalidateRequerySuggested();

            await Task.Run(() =>
            {
                _stopwatch.Start();

                for (var i = 0; _isRunning; i++)
                {
                    Star2Grid.GetDeltas();
                    Star2Grid.Update(
                        step: StepSizeVm.Value,
                        noise: NoiseLevelVm.Value,
                        nfDecay: NoiseFieldDecayVm.Value,
                        absDeltaToNoise: DeltaToNoiseVm.Value,
                        nfCpl: NoiseFieldCplVm.Value);

                    if (_cancellationTokenSource.IsCancellationRequested)
                    {
                        _isRunning = false;
                        _stopwatch.Stop();
                        CommandManager.InvalidateRequerySuggested();
                    }

                    if (i % (int)DisplayFrequencySliderVm.Value == 0)
                    {
                        Application.Current.Dispatcher.Invoke
                        (
                            UpdateUi,
                            DispatcherPriority.Background
                        );
                    }
                }
            }, _cancellationTokenSource.Token
                           );
        }