I don't want the user to interact with my application while a certain backgroundworker is busy (working). I created this bgw so that the application doesn't look frozen when it's working. But now users can move around in the app. How do I disable my form/application?
Thanks!
Perhaps set Enabled
to false
?
this.Enabled = false;
That is a bit drastic though, since it also prevents the form from being moved, resized or event closed. A better approach would be to put a Panel
control in your form, that has Dock = Fill
, and put our other controls into that Panel
. Then you can instead use the Enabled
property of the Panel
to prevent further user input.
Note thought that the user will be able to close the form, so that should be handled gracefully in some way.
You could also create a modal "busy splash" dialog that is shown when the background task starts and removed programmatically when the task ends. You could put a little animation in that box too to let the users know that something is going on. You would also need to make sure they don't close the dialog manually (only allow it to be closed programmatically).
I agree with @michael-todd in his comment above, disabling individual controls/navigation buttons/etc. while the background worker is working seems like a fairly good solution. This would give you fine-grained control over what the user can do during the specific background operation.
You could:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With