Dispose the old CancellationTokenSource atomically to avoid races

This commit is contained in:
Jack251970 2025-05-06 14:14:50 +08:00
parent b156afed0b
commit 2672512a62

View file

@ -1268,9 +1268,9 @@ namespace Flow.Launcher.ViewModel
var isHomeQuery = query.RawQuery == string.Empty;
_updateSource?.Dispose(); // Dispose old update source to fix possible cancellation issue
_updateSource = new CancellationTokenSource();
var oldSource = Interlocked.Exchange(ref _updateSource, new CancellationTokenSource());
_updateToken = _updateSource.Token;
oldSource?.Dispose(); // Dispose old update source to fix possible cancellation issue
ProgressBarVisibility = Visibility.Hidden;
_isQueryRunning = true;