December 2019
Intermediate to advanced
346 pages
9h 8m
English
If the methods return void instead of Task, the program will crash. You can try running the following code.
Here is a method returning void instead of Task:
private async static void Scenario4CallAsyncWithoutAwaitFromOutsideTryCatch(){ Task task = DoSomethingFaulty(); Console.WriteLine("This should not execute");}
And here is a call from the Main method:
public static void Main(){ Console.WriteLine("Main Method Started"); Scenario4CallAsyncWithoutAwaitFromOutsideTryCatch(); Console.WriteLine("In Main Method After calling method"); Console.ReadLine();}
There will be no output, as the program will crash.
Read now
Unlock full access