From c1de0e60d2ce5a045a0664616a4ae44250f30051 Mon Sep 17 00:00:00 2001 From: Michael Bucari-Tovo Date: Tue, 14 Feb 2023 23:07:40 -0700 Subject: [PATCH] Hopefully fix #492 --- .../ViewModels/ProcessQueueViewModel.cs | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/Source/LibationAvalonia/ViewModels/ProcessQueueViewModel.cs b/Source/LibationAvalonia/ViewModels/ProcessQueueViewModel.cs index 0b2f23fb..c1dda16e 100644 --- a/Source/LibationAvalonia/ViewModels/ProcessQueueViewModel.cs +++ b/Source/LibationAvalonia/ViewModels/ProcessQueueViewModel.cs @@ -44,11 +44,11 @@ namespace LibationAvalonia.ViewModels private bool _progressBarVisible; private decimal _speedLimit; - public int CompletedCount { get => _completedCount; private set { this.RaiseAndSetIfChanged(ref _completedCount, value); this.RaisePropertyChanged(nameof(AnyCompleted)); } } - public int QueuedCount { get => _queuedCount; private set { this.RaiseAndSetIfChanged(ref _queuedCount, value); this.RaisePropertyChanged(nameof(AnyQueued)); } } - public int ErrorCount { get => _errorCount; private set { this.RaiseAndSetIfChanged(ref _errorCount, value); this.RaisePropertyChanged(nameof(AnyErrors)); } } - public string RunningTime { get => _runningTime; set { this.RaiseAndSetIfChanged(ref _runningTime, value); } } - public bool ProgressBarVisible { get => _progressBarVisible; set { this.RaiseAndSetIfChanged(ref _progressBarVisible, value); } } + public int CompletedCount { get => _completedCount; private set => Dispatcher.UIThread.Post(() => { this.RaiseAndSetIfChanged(ref _completedCount, value); this.RaisePropertyChanged(nameof(AnyCompleted)); }); } + public int QueuedCount { get => _queuedCount; private set => Dispatcher.UIThread.Post(() => { this.RaiseAndSetIfChanged(ref _queuedCount, value); this.RaisePropertyChanged(nameof(AnyQueued)); }); } + public int ErrorCount { get => _errorCount; private set => Dispatcher.UIThread.Post(() => { this.RaiseAndSetIfChanged(ref _errorCount, value); this.RaisePropertyChanged(nameof(AnyErrors)); }); } + public string RunningTime { get => _runningTime; set => Dispatcher.UIThread.Post(() => { this.RaiseAndSetIfChanged(ref _runningTime, value); }); } + public bool ProgressBarVisible { get => _progressBarVisible; set => Dispatcher.UIThread.Post(() => { this.RaiseAndSetIfChanged(ref _progressBarVisible, value); }); } public bool AnyCompleted => CompletedCount > 0; public bool AnyQueued => QueuedCount > 0; public bool AnyErrors => ErrorCount > 0; @@ -78,8 +78,11 @@ namespace LibationAvalonia.ViewModels : _speedLimit > 1 ? 0.1m : 0.01m; - this.RaisePropertyChanged(nameof(SpeedLimitIncrement)); - this.RaisePropertyChanged(); + Dispatcher.UIThread.Post(() => + { + this.RaisePropertyChanged(nameof(SpeedLimitIncrement)); + this.RaisePropertyChanged(); + }); } } @@ -92,12 +95,12 @@ namespace LibationAvalonia.ViewModels ErrorCount = errCount; CompletedCount = completeCount; - this.RaisePropertyChanged(nameof(Progress)); + Dispatcher.UIThread.Post(() => this.RaisePropertyChanged(nameof(Progress))); } private void Queue_QueuededCountChanged(object sender, int cueCount) { QueuedCount = cueCount; - this.RaisePropertyChanged(nameof(Progress)); + Dispatcher.UIThread.Post(() => this.RaisePropertyChanged(nameof(Progress))); } public void WriteLine(string text)