title: How to run multiple tasks in c# and get an event on complete of these tasks?
body: <p>I am re-running a <code>Task</code> when its completed. Below is the function I call in the <code>Application_Start</code> of my application.</p>
  
  <pre><code>private void Run()
  {
      Task t = new Task(() =&gt; new XyzServices().ProcessXyz());
      t.Start();
      t.ContinueWith((x) =&gt;
      {
          Thread.Sleep(ConfigReader.CronReRunTimeInSeconds);
          Run();
      });
  }
  </code></pre>
  
  <p>I want to run multiple tasks, number which will be read from web.config app setttings.</p>
  
  <p>I am trying something like this, </p>
  
  <pre><code>private void Run()
  {
      List&lt;Task&gt; tasks = new List&lt;Task&gt;();
      for (int i = 0; i &lt; ConfigReader.ThreadCount - 1; i++)
      {
          tasks.Add(Task.Run(() =&gt; new XyzServices().ProcessXyz()));
      }
  
      Task.WhenAll(tasks);
  
      Run();
  }
  </code></pre>
  
  <p>Whats the correct way to do this ?</p>