Creating an async method with tasks
In this recipe, we will be looking at the asynchronous programming capabilities found in the C# language. C# has language-level asynchronous capabilities, and therefore you don't have to rely on a third-party library. If you have I/O operations, such as reading data from a network or from a database, you can utilize asynchronous programming. You can also use asynchronous programming for CPU-bound, expensive calculations.
Getting ready
Make sure you have Visual Studio 2017 updated. It is also assumed that you have prior experience in asynchronous programming and what it means.
How to do it...
- Open Visual Studio 2017.
- Click
File
|New
|Project
to create a project. - In the
New Project
dialog box, expand theOther Project Types
node in the left-hand pane and selectVisual Studio Solutions
. In the right-hand pane, selectBlank Solution
. - In the
Name:
textbox, typeChapter6.AsyncTasks
and, in theLocation:
textbox, select a path from the drop-down box or click on the...