Select to view content in your preferred language

Button.Click Event Queuing

612
0
07-17-2012 05:18 PM
norie
by
Regular Contributor
I've created a DockWindow which includes a few Buttons (System.Windows.Forms.Button)

My goal is to suppress multiple Click Events from being fired is succession. However, it seems that the Click events are being queued, then fired after the thread is free.

For example, I click the button once and the Click event is fired and the ProgressHelper dialog is shown. While the PH dialog is still being shown I can click again on the button. The application will wait for the btnExampleWork_Click handler to finish executing, then fire off the second instance of the Click handler. Is there anyway I can suppress multiple clicks?

I am positive that only one click handler is being assigned. I have also attempted it without the ProgressHelper and SuspendDisplay to no avail.

private bool MapIsBusy = false;

private void btnExampleWork_Click(object sender, EventArgs e) {
 btnExampleWork.Enabled = false;//even this doesn't help
 if (this.MapIsBusy) {
  return;
 }
 this.MapIsBusy = true;
 Trace.WriteLine("start");
 using (ProgressHelper ph = new ProgressHelper("Busy...", "Busy...", ""))
 using (IDisposable suspendDisplay = ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay.SuspendDisplay()) {
  //Do some intensive work
 }
 Trace.WriteLine("stop");
 this.MapIsBusy = false;
 btnExampleWork.Enabled = true;
}


Thank you!
0 Kudos
0 Replies