title: UI blocked when using await to run a time consuming task
body: <p>I want to build a folder cleaner program. It is expected to report deleted files  to a <code>TextBox</code> control at real-time. So I use <code>await Task.Run(() =&gt; CleanFolder(folderPath, progress))</code> function in my button click event. But the UI blocked when running. After a while when the <code>CheanFolder()</code> method run complete, all the deleted files are showed at one time.</p>
  
  <pre><code>namespace FolderCleaner
  {
      public partial class MainWindow : Window
      {
          string folderPath;
          string matchPattern;
  
          private void ButtonOpen_Click(object sender, RoutedEventArgs e)
          {
              FolderBrowserDialog fbd = new FolderBrowserDialog() { Description = "Select a folder" };
              if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
              {
                  folderPath = fbd.SelectedPath;
                  textBoxPath.Text = folderPath;
                  buttonClean.IsEnabled = true;
                  textBoxList.Text = "Folder path: " + folderPath + "\n";
              }
          }
  
          private async void ButtonClean_Click(object sender, RoutedEventArgs e)
          {
              matchPattern = textBoxPattern.Text;
              buttonOpen.IsEnabled = false;
              buttonClean.IsEnabled = false;
              Progress&lt;string&gt; progress = new Progress&lt;string&gt;(msg =&gt;
              {
                  textBoxList.AppendText("File deleted: " + msg + "\n");
                  textBoxList.CaretIndex = textBoxList.Text.Length;
                  textBoxList.ScrollToEnd();
              });
  
              try
              {
                  await Task.Run(() =&gt; CleanFolder(folderPath, progress));
  
                  textBoxList.AppendText("Mission complete!");
                  textBoxList.CaretIndex = textBoxList.Text.Length;
                  textBoxList.ScrollToEnd();
              }
              catch
              {
                  System.Windows.MessageBox.Show("Error!");
              }
              finally
              {
                  buttonOpen.IsEnabled = true;
              }
          }
  
          private void CleanFolder(string path, IProgress&lt;string&gt; progress)
          {
              var filePaths = Directory.EnumerateFiles(path, "*.*", System.IO.SearchOption.AllDirectories);
              foreach (var filePath in filePaths)
              {
                  var matchResult = Regex.Match(filePath, matchPattern);
                  if (matchResult.Success)
                  {
                      File.Delete(filePath);
                      progress.Report(filePath);
                  }
              }
          }
      }
  }
  </code></pre>