Advertisement
GeneralGDA

Await Test

Oct 11th, 2016
418
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.50 KB | None | 0 0
  1. class Program
  2. {
  3.     static async Task Foo()
  4.     {
  5.         Console.Out.WriteLine("Foo before");
  6.         await Task.Delay(TimeSpan.FromSeconds(20));
  7.         Console.Out.WriteLine("Foo after");
  8.     }
  9.  
  10.     static async void Bar()
  11.     {
  12.         Console.Out.WriteLine("Bar before");
  13.         await Foo();
  14.         Console.Out.WriteLine("Bar after");
  15.     }
  16.  
  17.     static void Main(string[] args)
  18.     {
  19.         Bar();
  20.         Console.Out.WriteLine("Main after Bar");
  21.         Thread.Sleep(30 * 1000);
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement