Skip to content

Commit 2672512

Browse files
committed
Dispose the old CancellationTokenSource atomically to avoid races
1 parent b156afe commit 2672512

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Flow.Launcher/ViewModel/MainViewModel.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1268,9 +1268,9 @@ private async Task QueryResultsAsync(bool searchDelay, bool isReQuery = false, b
12681268

12691269
var isHomeQuery = query.RawQuery == string.Empty;
12701270

1271-
_updateSource?.Dispose(); // Dispose old update source to fix possible cancellation issue
1272-
_updateSource = new CancellationTokenSource();
1271+
var oldSource = Interlocked.Exchange(ref _updateSource, new CancellationTokenSource());
12731272
_updateToken = _updateSource.Token;
1273+
oldSource?.Dispose(); // Dispose old update source to fix possible cancellation issue
12741274

12751275
ProgressBarVisibility = Visibility.Hidden;
12761276
_isQueryRunning = true;

0 commit comments

Comments
 (0)