First of all, thank you for providing a complete code sample. Well, not quite complete, because you did not show the essential code done by the designer (for code sample you should write that code by yourself and show: adding controls and adding event handlers to invocation lists of event), but anyone can reasonable guess what it its.
Of course you should observe something which can be interpreted as failure to disable a button. When I said that
button1.Enabled = false
works correctly, I meant the intended use of it, without any tricks which can disrupt behavior not of just feature, but the whole UI behavior. This trick is calling
Thread.Sleep
.
You should never ever call Thread.Sleep in a UI thread.
You re-enable button before you allow the application to run the event loop. To understand what's going on, add one line before that one:
button1.Enabled = false
Application.DoEvents();
No, one warning is not enough:
Attention! Don't write the above code in real applications. This is not a solution. Don't call Thread.Sleep
in UI thread.
—SA