title: detect when each task is complete
body: <p>I want to update a progressbar as each task is completed below.</p>
  
  <p>The method var continuation2 = Task.Factory.ContinueWhenAny(..... doesnt work.</p>
  
  <p>What is the correct way to do this?</p>
  
  <p><strong>C# Code</strong></p>
  
  <pre><code>  private void radButtonInsertManyErrors_Click(object sender, EventArgs e)
          {
              try
              {
                  radProgressBarStatus.Maximum = int.Parse(radTextBoxNumberofErrorsInsert.Text);
                  radProgressBarStatus.Value1 = 0;
  
  
                  Task&lt;int&gt;[] tasks = new Task&lt;int&gt;[int.Parse(radTextBoxNumberofErrorsInsert.Text)];
  
                  for (int i = 0; i &lt; int.Parse(radTextBoxNumberofErrorsInsert.Text); i++)
                  {
                      int x = i;
                      tasks[i] = new Task&lt;int&gt;(() =&gt;
                      {
  
                          //insert the error into table FA_Errors
                          Accessor.Insert_FAErrors(BLLErrorCodes.BLL_Error_Codes.Error_Log_Event_Login.ToString(),
                                                       (int)BLLErrorCodes.BLL_Error_Codes.Error_Log_Event_Login,
                                                       "Some Error", "",
                                                   MethodBase.GetCurrentMethod().DeclaringType.Namespace.ToString(),
                                                   MethodBase.GetCurrentMethod().Name.ToString(),
                                                   BLLErrorCategory.BLL_Error_Category.WEB_APP.ToString(),
                                                  "pc source", "damo",
                                                   sConn.ToString());
                          return 1;
  
  
                      });
                  }
  
                  var continuation = Task.Factory.ContinueWhenAll(
                              tasks,
                              (antecedents) =&gt;
                              {
                                  RadMessageBox.Show("Finished inserting errors ");
                              });
  
  
                  var continuation2 = Task.Factory.ContinueWhenAny(
                  tasks,
                  (antecedents) =&gt;
                  {
                          radProgressBarStatus.Value1++;
  
                  });
  
  
                  for (int i = 0; i &lt; int.Parse(radTextBoxNumberofErrorsInsert.Text); i++)
                      tasks[i].Start();
                  // Use next line if you want to block the main thread until all the tasks are complete
                  //continuation.Wait();
  
  
              }
              catch (Exception ex)
              {
  
                  MessageBox.Show(ex.Message.ToString());
  
              }   
  
          }
  </code></pre>