fork download
  1. using System;
  2. using System.Threading.Tasks;
  3.  
  4. public class Program
  5. {
  6. public static void Main()
  7. {
  8. var t = Test();
  9. t.Wait();
  10. Console.WriteLine($"completed {t.Id}");
  11.  
  12. t = Task.Run(Test);
  13. t.Wait();
  14. Console.WriteLine($"completed {t.Id}");
  15. }
  16.  
  17. public static async Task Test() {
  18. Console.WriteLine($"task {Task.CurrentId}");
  19. await Task.Yield();
  20. Console.WriteLine($"task {Task.CurrentId}");
  21. await Task.Yield();
  22. Console.WriteLine($"task {Task.CurrentId}");
  23. }
  24. }
Success #stdin #stdout 0.01s 33024KB
stdin
Standard input is empty
stdout
task 
task 
task 
completed 1
task 2
task 
task 
completed 3