April 2018
Intermediate to advanced
300 pages
7h 41m
English
Any method that is attributed with the async keyword (for C#) or Async for (Visual Basic) is called an asynchronous method. The async keyword can be applied to a method, anonymous method, or a Lambda expression, and the language compiler can execute that task asynchronously.
Here is a simple implementation of the TAP method using the compiler approach:
static void Main(string[] args)
{
var t = ExecuteLongRunningOperationAsync(100000);
Console.WriteLine("Called ExecuteLongRunningOperationAsync method, now waiting for it to complete"); t.Wait(); Console.Read(); } public static async Task<int> ExecuteLongRunningOperationAsync(int millis) { Task t = Task.Factory.StartNew(() => RunLoopAsync(millis)); await t; ...