delay in showing progressDialog

mc73

Well-Known Member
Licensed User
Longtime User
Dear friends,

I've noticed a logical perhaps, though very annoying behaviour: When I click on a button, I use a progressdialogshow2 with cancel set to false, in order to perform an operation without letting user to have the opportunity to either repress this button or other buttons during the operation, I have noticed that if the user is quick enough, he can click again on the same button or others, since there is a slight delay in showing the progress dialog box. Now, I know I can create a boolean flag in order to avoid other proccesses from running by clicking on other buttons, during the selected proccess (to be precise, in the very moment of initiating the event) or even disable them (IF there is no delay in this disabling!) but i'm surprised by the delay and also I have to rearrange much stuff in my code. I was wondering whether there would be a workaround of another type, as for example, if there would be somewhere a setting for arranging this very strange delay time. Thank you.
 

pluton

Active Member
Licensed User
Longtime User
For example you can put something like this (example of that problem with your button)

B4X:
Sub button1_click
button1.Enabled = False
ProgressDialogShow("Working...")
'start some code here
'...
'...
' somwhere at the end of code just put:
ProgressDialogHide
button1.Enabled = True 'if you need that this button can be enabled

End Sub
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
not exactly. user can click another button this way. so either we disable all buttons or we set a boolean flag, something like this:
if buttonclicked=true then return
buttonclicked=true
.... code ....
buttonclicked =false

at least this is what I did and it seems to work. yet this latency in initiating the progress dialog, took me quite some time to realize with its all subsequent problems.
thank you for your reply!
 
Upvote 0

pluton

Active Member
Licensed User
Longtime User
I don't know if this helps but did you try to put all buttons enabled to false somehow with this code.
On button click event

B4X:
For i = 0 To Activity.NumberOfViews - 1
    If Activity.GetView(i) Is Button Then 
    'put all buttons enabled to false
        Dim b As Button
        b = Activity.GetView(i)
      b.Enabled = False
    End If
Next
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
this would work but I cannot be sure that during the loop user cannot click on other buttons. I am afraid of the os, this is why I used this boolean flag, it's faster to denote it and not too much code :)
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
I will continue checking, I think, Erel, this was part of my open sockets' problem in the other thread :)
 
Upvote 0
Top