title: UI Thread Block
body: <p>I have created a simple WPF Application and added a button to the default window. When I click on the button, a simulated long working method(simulated using a Thread.Sleep(15000) is called. I am trying to make the button execute asynchronously however despite following online examples, the button and entire window locks as soon as I click and remains so until the Thread.Sleep(...) finishes. </p>
  
  <p>Any ideas why this is happening? </p>
  
  <p>Here is the code:</p>
  
  <pre><code>private void button1_Click(object sender, RoutedEventArgs e)
  {
     DoSomeAsyncWork();
  }
  
  private void DoSomeAsyncWork()
  {
       System.Windows.Threading.Dispatcher.Run();
       Thread thread = new System.Threading.Thread(
           new System.Threading.ThreadStart(
            delegate()
            {
                 Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() =&gt; Thread.Sleep(15000)));
            }
          ));
       thread.Start();
  }
  </code></pre>