Disable the GUI while an event is being serviced

How do you disable the GUI while a procedure is running? I have a button click (or any other UI event) that I am processing and the user is clicking the button again because my response is not immediate. This then launches the event again!

The same issue is true if I need to wait for a response say from a web service. I need to update the display while I’m waiting for the service call to complete.

How do you do this?

Thanks in advance.

Jim

I would use a ProgressWheel or a toast message (small box with a message that I close after a while) or both to show the user something is happening, and disable the button to prevent re-click. Then enable the button back when the operation is complete.

Hi Michael,

No updates occur at the gui until the routine has finished. So how you disable the button?

So if I click cmdTest and in the Action event I do this:

cmdTest.Enabled = False

‘’ Do something that takes a few seconds

cmdTest.Enabled = True

you never see the button get disabled!

Is your process running in a thread. If so, could you check the thread.state to ensure it’s not running before you start the process?

Could you set a boolean property when the process starts and check that value?

Couple of ideas you may be able to run with/develop…

Add a 10 ms timer to your webpage which contains your routine in the Action event. Turn it off in the inspector.

In the button :

Sub Action() me.Enabled = false Timer1.mode = Timer.ModeSingle Timer1.enabled = true End Sub

You are right, the GUI does not get updated while an event is not finished. So you use a timer to end the current event, update the GUI, and trigger another event where the process starts :slight_smile:

To finish what Pat was thinking…

If you have a long running process, put it into a thread and run it there. Run a client side timer, which keeps track of the progress of the thread. In the mean time, show a modal dialog which tells the user that the process is running. When the process completes, close the dialog.

Super! Thanks for all your replies!