Skip to content

Instantly share code, notes, and snippets.

@cpoDesign
Created November 1, 2017 08:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cpoDesign/626a33948cfe27c8609728429545a5d9 to your computer and use it in GitHub Desktop.
Save cpoDesign/626a33948cfe27c8609728429545a5d9 to your computer and use it in GitHub Desktop.
public async Task<IHttpActionResult> MethodA()
{
var customer = new Customer();
customer.Widgets = await _widgetService.GetAllWidgets();
customer.Foos = await _fooService.GetAllFoos();
return Ok(customer);
}
public async Task<IHttpActionResult> MethodB()
{
var customer = new Customer();
var getAllWidgetsTask = _widgetService.GetAllWidgets();
var getAllFoosTask = _fooService.GetAllFos();
Task.WaitAll(new List[] {getAllWidgetsTask, getAllFoosTask});
customer.Widgets = getAllWidgetsTask.Result;
customer.Foos = getAllFoosTask.Result;
return Ok(customer);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment