Skip to content

Commit 6f197d9

Browse files
committed
Work on concurrency
1 parent 2d02183 commit 6f197d9

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

SmartImage.Lib 3/SearchClient.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using Microsoft.Extensions.Logging;
1616
using Novus.FileTypes;
1717
using SmartImage.Lib.Engines;
18+
using SmartImage.Lib.Engines.Impl.Search;
1819
using SmartImage.Lib.Model;
1920
using SmartImage.Lib.Results;
2021
using SmartImage.Lib.Utilities;
@@ -98,7 +99,7 @@ public async Task<SearchResult[]> RunSearchAsync(SearchQuery[] query, Cancellati
9899

99100
token ??= CancellationToken.None;
100101
var tasks = query.SelectMany(e => GetSearchTasks(e, token.Value)).ToList();
101-
102+
102103
var results = new SearchResult[tasks.Count];
103104
int i = 0;
104105

@@ -235,7 +236,6 @@ private void OpenResult(SearchResult result)
235236
#endif
236237

237238
}
238-
239239
public List<Task<SearchResult>> GetSearchTasks(SearchQuery query, CancellationToken token)
240240
{
241241
if (query.Upload is not { }) {
@@ -244,9 +244,11 @@ public List<Task<SearchResult>> GetSearchTasks(SearchQuery query, CancellationTo
244244

245245
var tasks = Engines.Select(e =>
246246
{
247-
return e.GetResultAsync(query, token);
248-
}).ToList();
247+
var res = e.GetResultAsync(query, token);
249248

249+
return res;
250+
}).ToList();
251+
250252
return tasks;
251253
}
252254

0 commit comments

Comments
 (0)