title: Implementing a pause in WPF
body: <p>Here you have a simple WPF program:</p>
  
  <pre><code>&lt;!-- Updater.xaml --&gt;
  &lt;Window x:Class="Update.Updater"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          Title="MainWindow" Height="350" Width="525"
          DataContext="{Binding RelativeSource={RelativeSource Self}}"&gt;
      &lt;Grid&gt;
          &lt;StackPanel&gt;
              &lt;Button Click="Button_Click" Height="50"&gt;&lt;/Button&gt;
              &lt;Label Content="{Binding Label1Text}" Height="50"&gt;&lt;/Label&gt;
              &lt;Label Content="{Binding Label2Text}" Height="50"&gt;&lt;/Label&gt;
          &lt;/StackPanel&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt;
  
  // Updater.xaml.cs
  using System.Threading;
  using System.Windows;
  
  namespace Update
  {
      public partial class Updater : Window
      {
          public Updater()
          {
              InitializeComponent();
          }
  
          private void Button_Click(object sender, RoutedEventArgs e)
          {
              Label1Text = "It is coming...";
              Thread.Sleep(3000);
              Label2Text = "It is here!";
          }
  
          public string Label1Text
          {
              get { return (string)GetValue(CategoryProperty); }
              set { SetValue(CategoryProperty, value); }
          }
  
          static readonly DependencyProperty CategoryProperty = DependencyProperty.Register("Label1Text", typeof(string), typeof(Updater));
  
          public string Label2Text
          {
              get { return (string)GetValue(Label2TextProperty); }
              set { SetValue(Label2TextProperty, value); }
          }
  
          static readonly DependencyProperty Label2TextProperty = DependencyProperty.Register("Label2Text", typeof(string), typeof(Updater));
      }
  }
  </code></pre>
  
  <p>The intention is that when you click the button, the first label displays <code>It is coming...</code>. Then the program sleeps for 3 seconds, and finally the second label displays <code>It is here!</code>. However, the naïve implementation below doesn't work. If you run it and click the button the following happens: The program sleeps for 3 seconds, and then the two label texts are displayed simultaneously. Do you know how to correct the program so that it does as intended?</p>