var seeds = new [] {1, 2, 3, 4};
從每個種子我想運行執行一些計算與種子異步方法的集合:
async Task<int> Calculation(int seed);
我的目標是進行選擇這樣的:
var results = from seed in seeds
let calculation = await Calculation(seed)
select new { seed, calculation };
不幸的是,這句法沒有使用LINQ不允許的。
如何讓「結果」變量包含種子和計算?
(我將不勝感激任何答案,但特別是如果它使用System.Reactive的Observable
)
http://stackoverflow.com/questions/21868087/how-to-await- a-list-of-tasks-asynchronously-using-linq這裏由斯蒂芬·克萊裏回答,關於它。 – mybirthname