title: Task.ContinueWith query
body: <p>I`m new to TPL and need some help in understanding .continueWith. Can you pls tell me what is wrong in first task-continuation and how is second one correct?</p>
  
  <pre><code>List&lt;int&gt; input = new List&lt;int&gt; { 1, 2, 3, 4, 5 };
  
   //Gives cast error at the second continuation: cannot implicitly convert 
   //Task to Task&lt;List&lt;int&gt;&gt;
      Task&lt;List&lt;int&gt;&gt; task = Task.Factory.StartNew&lt;List&lt;int&gt;&gt;(
          (state) =&gt; { return (List&lt;int&gt;)state; }, input)
  
          .ContinueWith&lt;List&lt;int&gt;&gt;(
          (prevTask =&gt; { return (List&lt;int&gt;)prevTask.Result; }))
  
          .ContinueWith(
          (prevTask =&gt; { Console.WriteLine("All completed"); }));
  
      //Works fine
      Task&lt;List&lt;int&gt;&gt; task1 = Task.Factory.StartNew&lt;List&lt;int&gt;&gt;(
          (state) =&gt; { return (List&lt;int&gt;)state; }, input);
  
      task1.ContinueWith&lt;List&lt;int&gt;&gt;(
          (prevTask =&gt; { return (List&lt;int&gt;)prevTask.Result; }))
  
          .ContinueWith(
          (prevTask =&gt; { Console.WriteLine("All completed"); }));
  </code></pre>