Closed
Description
Description
Through the code, we can find some pieces of code looking like :
foreach (obj o in objectCollection)
{
await AsyncMethod(o);
}
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
- Whole solution
Gains
- A gain in performances, depending on how often the code is used.
Requirements
Replacing
foreach (obj o in objectCollection)
{
await AsyncMethod(o);
}
By
var tasksCollections = objectCollection.Select(o=> AsyncMethod(o));
await Task.WhenAll(tasksCollections );
Comments
No response
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
✅ Done