Last active
October 13, 2018 15:18
-
-
Save jesuscampos/a1dc83b50a91b6f4bc50ddfe8bdf394a to your computer and use it in GitHub Desktop.
Async
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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