I have tons of WCF service calls. Simply:
foreach (var node in tree.Nodes) {
// some preparing code here
....
treeView.TocStorageInstance.UpdateNode(node) //network call
}
I'd like to parallel all these network calls which are executing one by one - as I see in the Fiddler.
Trying the next approach is not successful:
var nodesToUpdate = new List<Task>();
foreach (var node in tree.Nodes) {
// some preparing code here
....
nodesToUpdate.Add(await Task.Run(() => treeView.TocStorageInstance.UpdateNode(node)));
}
await Task.WhenAll(nodesToUpdate);
All calls still execute one-by-one in foreach
statement.
Is it possible at all?