What actually occurs on clicking a button twice if the code in the button takes some time to run and the second click happens before the code in the first click is complete.
I know I can disable the button (and do in some places but need to add more).
It does NOT appear the button click is Queued and happens after the first click code finishes.
Does the second event run at the same time in a different thread (asynchronously)?
Does it get private memory space not related to the first click?
Thanks.
Is the second click fast enough to be considered a double click? If so you could tweak it some that way to ignore it, etc. May need to add the class style for the window for it to send DblClicks too.
I am not looking to catch double clicks but just to understand how Windows works.
This has surfaced because of users that always seem to double click everything since they don't understand when to double and when to single click.
Disabling the button on "long running" functions is the real answer.
Thanks.
The easy solution to not allowing the same piece of code to execute more than once is to add a static variable to your function and set and release it to catch the second incoming request....
For example,
Function MyFunction() As Long
Static IsCodeRunning As Long
' If previously actioned code has not yet finsihed running then exit
If IsCodeRunning Then Exit Function
' Set the flag to indicate that the code is executing
IsCodeRunning = %TRUE
.
.
. ' Do your actual code here....
.
.
' Reset the flag to indicate that the code has finished executing
IsCodeRunning = %FALSE
Exit Function
ExitOut:
IsCodeRunning = %FALSE
End Function
... or something along those lines above.