Created
June 18, 2013 00:54
-
-
Save v2m/5801835 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Run().Wait(); | |
} | |
static async Task Run() | |
{ | |
var tcs = new TaskCompletionSource<object>(); | |
Task t1 = null; | |
Console.WriteLine("1:" + Environment.CurrentManagedThreadId); | |
t1 = Task.Factory.StartNew(() => | |
{ | |
Console.WriteLine("2:" + Environment.CurrentManagedThreadId); | |
System.Threading.Thread.Sleep(1000); | |
tcs.SetResult(null); | |
} | |
); | |
Console.WriteLine("3:" + Environment.CurrentManagedThreadId); | |
await tcs.Task; | |
Console.WriteLine("4:" + Environment.CurrentManagedThreadId); | |
t1.Wait(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment