views:

119

answers:

2

On clicking a button, a query is executed in a background worker. It is asynchronous so that I can change the button to "Cancel" so the user can cancel the process if it runs longer than expected. This all works fine.

But, I do not want the user to be able to navigate away from this location to do other things on the form. They must be able to click the Cancel button or close the form, but nothing else.

+6  A: 

Then I suggest you disable the other controls on the form when you begin processing your query, and when the background worker completes, re-enable them.

mquander
+1  A: 

the best way to do this is to create a method like DisableControls() which contains the disable commands for all the other controls.

Once the async work is complete, on the callback, call a method like EnableControls() to revers the process.

miguel