title: Disable Winforms button while OnClick code executes in background
body: <p>I have some code in my "button_click" action. I want to disable the button during this code working.</p>
  
  <pre><code>    private void button1_Click(object sender, RoutedEventArgs e)
      {
          button1.IsEnabled = false;
          // some code (its take about 2-5 sec)
          button1.IsEnabled = true;
      }
  </code></pre>
  
  <p>But this doesn't work. The button never disables.</p>