There are 4 actions performed by click a button, those 4 actions may take up to 30 sec. I would like to use a progressing bar with "Indeterminate" on to show there is something going on in the background, otherwise the user may think there is nothing happening, so he or she may click the button multiple times.
The idea is when click the button, the progressing bar visible will be 1, so the user will see the progressing bar on the screen. When all 4 transactions are completed, the progressing bar visible will be 0. So the user can understand the transactions are done.
You can prevent multiple button clicks by toggling off the button's enabled property at the beginning of the script.
Then, expanding upon the previous posts, call the long running task asynchronously using invokeLayer in the asynchronous function anytime something needs to be done in the gui such as updating the progress bar or reenabling the button when everything is done.