Skip to content

Commit 2f4e140

Browse files
committed
Improve query async local function
1 parent d785991 commit 2f4e140

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,16 +1204,20 @@ private async Task QueryResultsAsync(int? searchDelay, bool isReQuery = false, b
12041204
}
12051205

12061206
// Local function
1207-
async Task QueryTaskAsync(PluginPair plugin, bool reSelect = true)
1207+
async ValueTask QueryTaskAsync(PluginPair plugin, bool reSelect = true)
12081208
{
12091209
// Since it is wrapped within a ThreadPool Thread, the synchronous context is null
12101210
// Task.Yield will force it to run in ThreadPool
12111211
await Task.Yield();
12121212

1213+
if (_updateSource.Token.IsCancellationRequested)
1214+
return;
1215+
12131216
IReadOnlyList<Result> results =
12141217
await PluginManager.QueryForPluginAsync(plugin, query, _updateSource.Token);
12151218

1216-
_updateSource.Token.ThrowIfCancellationRequested();
1219+
if (_updateSource.Token.IsCancellationRequested)
1220+
return;
12171221

12181222
IReadOnlyList<Result> resultsCopy;
12191223
if (results == null)

0 commit comments

Comments
 (0)