Skip to content

Instantly share code, notes, and snippets.

@pcibraro
Created November 14, 2012 19:16
Show Gist options
  • Save pcibraro/4074119 to your computer and use it in GitHub Desktop.
Save pcibraro/4074119 to your computer and use it in GitHub Desktop.
Await in Foreach
public async Task<IEnumerable<SearchResult>> Get()
{
var providers = this.locator.GetAllProviders(resource);
var allResults = new List<SearchResult>();
foreach (var provider in providers)
{
var results = await provider.Search("foo");
allResults.AddRange(results);
}
return allResults;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment