Skip to content

Instantly share code, notes, and snippets.

@pongo
Created September 29, 2012 15:16
Show Gist options
  • Select an option

  • Save pongo/3804314 to your computer and use it in GitHub Desktop.

Select an option

Save pongo/3804314 to your computer and use it in GitHub Desktop.
[c#] async-await example from video http://www.asp.net/vnext/overview/videos/async-and-await
public async Task<ActionResult> Index() {
var contacts = Client.DownloadStringTaskAsync("api/contacts");
var temperature = Client.DownloadStringTaskAsync("api/temperature");
var location = Client.DownloadStringTaskAsync("api/location");
await Task.WhenAll(contacts, temperature, location);
ViewBag.Temperature = temperature.Result;
ViewBag.Location = location.Result;
ViewBag.Contacts = contacts.Result;
return View();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment