-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code quality: Await is being used inside foreach loop #10268
Comments
Marking this as ready to build |
Consider that doing this in AddAllItemsToSidebar would change the order of the displayed items. Some more changes are required. |
I think every scenario needs to be evaluated. |
I did the tests on |
@gave92 do you have anything specific in mind? |
It's been a while sorry I do not recall :) |
await Task.WhenAll(FavoriteItems.AsParallel().AsOrdered().Select(path => AddItemToSidebarAsync(path))); Edit |
Description
Through the code, we can find some pieces of code looking like :
It is not the most efficient way of performing the tasks, since it means we are waiting for each task to be done before performing the next one. It would be much faster to perform all the task using the
Task.WhenAll
process.As an exemple, using this process inside the
AddAllItemsToSidebar
method allowed for a gain of 15 % in speed.Concerned code
Gains
Requirements
Replacing
By
Comments
No response
The text was updated successfully, but these errors were encountered: