Пример #1
0
 private void UpdateUi()
 {
     GridValsVm.UpdateData(Star4Grid.CurValuesAsP2Vs());
     GridDeltasVm.UpdateData(Star4Grid.CurDeltasAsP2Vs());
     AbsDelta   = A2dUt.flattenRowMajor(Star4Grid.Stars).Sum(st => st.AbsDelta);
     NoiseField = A2dUt.flattenRowMajor(Star4Grid.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++)
                {
                    Star4Grid.GetDeltas();
                    Star4Grid.Update(
                        step: StepSizeVm.Value,
                        noise: NoiseLevelVm.Value,
                        nfDecay: NoiseFieldDecayVm.Value,
                        absDeltaToNoise: DeltaToNoiseVm.Value,
                        nfCpl: NoiseFieldCplVm.Value,
                        ffCpl: FixedFieldCplVm.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
                           );
        }