windows runtime - How to await a method in a Linq query -
trying use await keyword in linq query , this:
the 'await' operator may used in query expression within first collection expression of initial 'from' clause or within collection expression of 'join' clause
sample code:
var data = (from id in ids let d = await loaddataasync(id) select d); is not possible await in linq query, or need structured different way?
linq has limited support async/await. linq-to-objects, useful operation know of select async delegate (which results in sequence of tasks).
list<t> data = new list<t>(); foreach (var id in ids) data.add(await loaddataasync(id)); if can loaddataasync in parallel safely, example rewritten as:
t[] data = await task.whenall(ids.select(id => loaddataasync(id)));
Comments
Post a Comment