Example #1
0
 void WrongWay()
 {
     // this will be a deadlock, there's actually only one thread. The async methods run on the same thread!
     Task <Sandwich>        sandwichTask = MakeBLT();
     TaskAwaiter <Sandwich> awaiter      = sandwichTask.GetAwaiter();
     Sandwich result = awaiter.GetResult();
 }
Example #2
0
 async Task PrintResult(Task <Sandwich> sandwichTask)
 {
     Sandwich sandwich = await sandwichTask; // then (sandwich) =>
     {
         WriteLine($"Your {sandwich.ToString()} is done!");
     }
 }