From 788cb3cc16cc639ffbe1d55acb3ab20f4f900396 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Tue, 6 May 2025 19:17:33 +0800 Subject: [PATCH] Revert "Dispose the old CancellationTokenSource atomically to avoid races" This reverts commit 2672512a62503a76d72777c3716cfe48dc1465b7. --- Flow.Launcher/ViewModel/MainViewModel.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 383256dcc..175f4ff84 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -1268,9 +1268,9 @@ namespace Flow.Launcher.ViewModel var isHomeQuery = query.RawQuery == string.Empty; - var oldSource = Interlocked.Exchange(ref _updateSource, new CancellationTokenSource()); + _updateSource?.Dispose(); // Dispose old update source to fix possible cancellation issue + _updateSource = new CancellationTokenSource(); _updateToken = _updateSource.Token; - oldSource?.Dispose(); // Dispose old update source to fix possible cancellation issue ProgressBarVisibility = Visibility.Hidden; _isQueryRunning = true;