Skip to content

Instantly share code, notes, and snippets.

@jesuscampos
Last active October 13, 2018 15:18
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 jesuscampos/a1dc83b50a91b6f4bc50ddfe8bdf394a to your computer and use it in GitHub Desktop.
Save jesuscampos/a1dc83b50a91b6f4bc50ddfe8bdf394a to your computer and use it in GitHub Desktop.
Async
public class HomeController: Controller
{
public async Task<IActionResult> GetAsync()
{
var result = await DoWork(100);
return View(result);
}
public Task<long> DoWork(int n)
{
return Task.Run(() =>
{
// CPU-Bound work
// ...
return fibonacciNumber;
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment