title: Task.WaitAll() without locking up the main UI
body: <p>I have the following job sent to multiple threads for processing from main UI thread.
  Upon completion of all jobs, I need to issue a message "Job completed" to let the user know it's done.</p>
  
  <pre><code>LimitedTaskScheduler scheduler = new LimitedTaskScheduler(4);
  TaskFactory factory = new TaskFactory(scheduler);
  MessageBox.Show("Job started");
  for (int i = 0; i &lt; rows.Length; i++)
  {
    string tabName = rows[i]["TableName"].ToString();
    int nStatus;
    factory.StartNew&lt;int&gt;(() =&gt;
    {
     nStatus = ProcessTable(tabName);
     return nStatus;
    });
  }
  MessageBox.Show("Job finished");
  </code></pre>
  
  <p>In the above code, MessageBox.Show("Job finished"); is executed immediately after the the tasks are sent, which is wrong.
  If I use Task.WaitAll(); it will lock up the main UI thread which I don't want it to.</p>
  
  <p>My question is what is the best way to display "Job finished" message after all tasks are completed while not locking up the main UI thread?</p>
  
  <p>Thanks in advance.</p>