Getting ready

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 until the called asynchronous method has completed. Keep in mind that an asynchronous method that returns a type of Task basically does not return an operand. Therefore, if it was written as a synchronous method, it would be ...

Get C# 7 and .NET Core Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.