Skip to content

Instantly share code, notes, and snippets.

@parmarnishant
Created April 26, 2013 15:39
Show Gist options
  • Select an option

  • Save parmarnishant/5468199 to your computer and use it in GitHub Desktop.

Select an option

Save parmarnishant/5468199 to your computer and use it in GitHub Desktop.
async
IEnumerable<Task<Image>> tasks = s_Domains.Select(GetFavicon);
// The IEnumerable from Select is lazy, so evaluate it to start the tasks
tasks = tasks.ToList();
Task<Image[]> allTask = Task.WhenAll(tasks);
Then, all we have left to do is await the allTask, and use its results:
Image[] images = await allTask;
foreach (Image eachImage in images)
{
AddAFavicon(eachImage);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment