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: Reduced usage of Await inside foreach loops #15005
Conversation
d71d998
to
1137d19
Compare
Good morning @yaira2! fixed the places that you asked, the other places can run concurrently? |
The code for clearing the jumplist can, but I'm pretty sure the other ones need to run in a specific order. It might be best to revert those changes and just add a comment for future reference. |
@yaira2 I think now it's ready, the only places that have |
Thank you for staying on top of this! I'll try to finish my review in the next few days. Just a quick tip regarding "conversations", instead of marking them as resolved, it's best to add a comment so the reviewer can see it and complete the conversation if they are happy with the solution. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you changing LINQ ForEach to foreach loop? Since lambda expressions in ForEach are not awaited, awaiting them in foreach loop is not good for performance.
This answer explains well the difference. Then we can migrate the changed .ForEach with |
Does this mean that this PR will not only improve performance, but will also include modifications to guarantee order where order is important, even at the expense of performance?
Awaiting |
What about |
The issue is whether or not to await |
// Await all removal tasks to complete concurrently | ||
await Task.WhenAll(source.Select(x => jumpListService.RemoveFolderAsync(x.Path))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if we should await this. This is deleting items from the jump list, which is different from deleting the items itself, so it may be performed asynchronously.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree
Co-authored-by: hishitetsu <[email protected]>
Co-authored-by: hishitetsu <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably my last comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🎉
Resolved / Related Issues
Related to Code quality: Await is being used inside foreach loop #10268
Validation
How did you test these changes?
Fixed every
.ForEach
async void, except two edge cases atItemViewModel.cs
,in the methodUpdateDateDisplay
and the propertyEnabledGitProperties
.