title: Best way to deal with users double-clicking buttons in a winforms app?
body: <p>I'm working on a WinForms app and I have a user control in it.  The buttons in the user control raise events up to the form to be handled by other code.  One of the buttons starts some processses that will cause problems if they run simultaneously.  I have logic in the code to manage the state so typically a user can't run the process if it's already running.  However, if the user double-clicks the button it will start the process twice so quickly that it's tough for me to prevent it.</p>
  
  <p>I'm wondering, what's the best way to handle this?</p>
  
  <p>I started out by disabling the button in the click event but the second click comes in before the first click causes the button to be disabled.  Setting other flags in the code didn't catch it either.</p>
  
  <p>I'm considering adding some sort of sync lock on the code that raises the event but I'm wondering if any of you have a better idea.  </p>
  
  <p>Since this project is mostly complete I'm looking for answers that don't involve a radical rewrite of the app (like implementing the composite application block), however, feel free to post those ideas too since I can use them in my next projects.</p>