In asynchronous programming, the async methods can have three possible return types. These are as follows:
- void
- Task
- Task<TResult>
We will take a look at each return type in the following recipe.
In asynchronous programming, the async methods can have three possible return types. These are as follows:
We will take a look at each return type in the following recipe.
What could be the use of a void return type in asynchronous methods? Generally, void is used with event handlers. Just bear in mind that void returns nothing, so you can't wait for it. Therefore, if you call a void return type asynchronous method, your calling code should be able to continue executing code without having to wait for the asynchronous method to complete.
With asynchronous methods that have a return type of Task, you can utilize the await operator to pause the execution of the current thread...