I have something like this:
void ClickHandler() // Called from several places
{ // Try to prevent queuing accidental extra clicks during lengthy operation
GetMainWindow().IsEnabled = false; // "GetMainWindow()" you know what I mean
DoLengthyStuffInThisThread(); // Yes, I know I shouldnt
PresentResult();
GetMainWindow().IsEnabled = true;
}
That's it basically. To clarify though:
Even though I have set IsEnabled = false it does not have the desired effect, my extra clicks go through during the operation. (It does have an effect if I return without restoring the value.) I assume that normally my thread needs to return in order for the disabling to to have effect but I'd rather not create an extra thread.