Can I repeat same tasks in buttonclick C#
<pre><code>private void button1_Click(object sender, EventArgs e)
{
    for (int iter = 0; iter &lt; 3; ++iter)
    {
        //...code for defining some matrix elements and cell id  
        try
        {
            var firstTask = new Task(() =&gt; invokedisplaymatrix(MatrixInfoValues));
            var secondTask = firstTask.ContinueWith((t) =&gt; invokedisplayblankmatrix(MatrixInfoValues));
            var thirdTask = secondTask.ContinueWith((t) =&gt; invokedisplayanswermatrix(MatrixInfoValues));
            firstTask.Start();
        }
        catch (AggregateException error)
        {
            Console.WriteLine(error.Message);
        }
    }
}
</code></pre>

<p>I have a number of tasks to be performed in my code, which is activated when a button is pressed in windows form application. I need to repeat the same procedures for n number of iterations. But When I debug the program, I can see that control goes to increment 'iter' after tasks and only tasks for the final 'iter' are  performed. Can anyone help to fix the issue?</p>
