ContinueWith and Result of the task

That’s because ContinueWith creates completely new task, result of which you ignore, and instead print the result of the first one, which is rightfully 43. Try the following snippet:

Task<int> t = new Task<int>(() => { return 43; });
t.Start();
var t2 = t.ContinueWith((i) => {return i.Result * 2; });

Console.WriteLine("i = {0}", t2.Result.ToString());

Leave a Comment