Skip to content

Commit e205947

Browse files
committed
Check token after new item added
1 parent f8fa9ba commit e205947

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Flow.Launcher/ViewModel/ResultsViewModel.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,11 @@ public void Update(List<ResultViewModel> newItems, CancellationToken token = def
354354
{
355355
// RemoveAll will not check token cancellation, so it will clear existing results
356356
if (Count != 0) RemoveAll(newItems.Count);
357+
358+
// After results are removed, we need to check the token cancellation
359+
// so that we will not add new items from the cancelled queries
360+
if (token.IsCancellationRequested) return;
361+
357362
AddAll(newItems);
358363
editTime++;
359364
return;
@@ -362,6 +367,11 @@ public void Update(List<ResultViewModel> newItems, CancellationToken token = def
362367
{
363368
// Clear will not check token cancellation, so it will clear existing results
364369
Clear();
370+
371+
// After results are removed, we need to check the token cancellation
372+
// so that we will not add new items from the cancelled queries
373+
if (token.IsCancellationRequested) return;
374+
365375
BulkAddAll(newItems);
366376
if (Capacity > 8000 && newItems.Count < 3000)
367377
{

0 commit comments

Comments
 (0)