Created
December 26, 2012 22:35
-
-
Save cbilson/4383667 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class MyExperiment | |
{ | |
public static void RegularMethod() | |
{ | |
DoSomethingAsync(); | |
Console.WriteLine("after starting async stuff"); | |
Thread.Sleep(15000); | |
} | |
public async static void DoSomethingAsync() | |
{ | |
Console.WriteLine("before calling async method..."); | |
await DoSomethingSlow(1); | |
await DoSomethingSlow(2); | |
Console.WriteLine("after calling task.Result"); | |
} | |
public static Task DoSomethingSlow(int i) | |
{ | |
return Task.Factory.StartNew(() => | |
{ | |
Thread.Sleep(5000); | |
Console.WriteLine("{1:MM/dd/yyyy hh:mm:ss.fff tt}: done with {0}", i, DateTime.Now); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment