Sunday, August 26, 2012

Tpl TaskCompletionSource on WP7 completes immediately

Tpl TaskCompletionSource on WP7 completes immediately

I am using Robert McLaws TPL library (http://nuget.org/packages/System.Threading.Tasks/3.0.1) on WP7 (Mango).

 var t1 = new TaskCompletionSource<int>().Task;  var t2 = t1.ContinueWith(t =>             {                 Debug.WriteLine("Hello");             }, TaskContinuationOptions.OnlyOnRanToCompletion);  t1.Start(); 

"Hello" is printed to the debug console. But i have nowhere set the result on the TaskCompletionSource using SetResult or TrySetResult.

I was excepting the above code to never output "hello" as task t1 never finishes.

What am i doing wrong?

Answers & Comments...




No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog