Example of LINQ Select
and ToDictionary
with parallel execution of tasks
var dataSource = new List<object>() { "aaa" , "bbb" };
var tasks = dataSource.Select(async data => new { Key = data.ToString(), Value = await AsyncDoSomething(data.ToString()) });
var results = await Task.WhenAll(tasks);
Dictionary<string, int> dictionary = results.ToDictionary(pair => pair.Key, pair => pair.Value);
Adapted from this Stackoverflow answer.
Reference: