Once i launch a win forms application, i create a background worker to do some initialization. While this initialization happens, i want all the buttons in the form to stay disabled.
I was thinking whats the best way to do this. One straightforward approach i could think of is setting a flag in the thread’s completed event. Is there any other better approach?
In cases like this I typically put the controls into a
Panel, disable the panel when the background process is started, and then enable it again when the work is done. This way you don’t need to keep track of theEnabledstate for each individual control. Disbling the panel and starting the background worker can be done in the form’sLoadevent handler (orOnLoadoverride, depending on your coding style).