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.

Revisions

  1. parmarnishant created this gist Apr 26, 2013.
    11 changes: 11 additions & 0 deletions async
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    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);
    }
    1 change: 1 addition & 0 deletions new_gist_file
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    _