title: Executing tasks in parallel
body: <p>Ok, so basically I have a bunch of tasks (10) and I want to start them all at the same time and wait for them to complete. When completed I want to execute other tasks. I read a bunch of resources about this but I can't get it right for my particular case...</p>
  
  <p>Here is what I currently have (code has been simplified):</p>
  
  <pre><code>public async Task RunTasks()
  {
      var tasks = new List&lt;Task&gt;
      {
          new Task(async () =&gt; await DoWork()),
          //and so on with the other 9 similar tasks
      }
  
  
      Parallel.ForEach(tasks, task =&gt;
      {
          task.Start();
      });
  
      Task.WhenAll(tasks).ContinueWith(done =&gt;
      {
          //Run the other tasks
      });
  }
  
  //This function perform some I/O operations
  public async Task DoWork()
  {
      var results = await GetDataFromDatabaseAsync();
      foreach (var result in results)
      {
          await ReadFromNetwork(result.Url);
      }
  }
  </code></pre>
  
  <p>So my problem is that when I'm waiting for tasks to complete with the <code>WhenAll</code> call, it tells me that all tasks are over even though none of them are completed. I tried adding <code>Console.WriteLine</code> in my <code>foreach</code> and when I have entered the continuation task, data keeps coming in from my previous <code>Task</code>s that aren't really finished.</p>
  
  <p>What am I doing wrong here?</p>