Created
August 19, 2011 13:42
-
-
Save marek-safar/1156815 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
using System; | |
using System.Threading; | |
using System.Threading.Tasks; | |
class C | |
{ | |
public static void Main () | |
{ | |
var tsc = new TaskCompletionSource<int> (); | |
Thread t1 = new Thread (() => { | |
while (true) { | |
tsc.TrySetCanceled (); | |
} | |
}); | |
/* | |
Thread t2 = new Thread (() => { | |
while (true) { | |
tsc.TrySetResult (2); | |
} | |
}); | |
*/ | |
Thread t3 = new Thread (() => { | |
while (true) { | |
tsc.TrySetException (new NotImplementedException ()); | |
} | |
}); | |
t1.Start (); | |
//t2.Start (); | |
t3.Start (); | |
while (true) { | |
t1.Suspend (); | |
// t2.Suspend (); | |
t3.Suspend (); | |
tsc = new TaskCompletionSource<int> (); | |
t1.Resume (); | |
// t2.Resume (); | |
t3.Resume (); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment