PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Mark Strickland on April 14, 2006, 11:09:13 AM

Title: What happens if (button push)?
Post by: Mark Strickland on April 14, 2006, 11:09:13 AM
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.
Title: What happens if (button push)?
Post by: Roger Garstang on April 14, 2006, 12:01:31 PM
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.
Title: Not really trying to catch a double click
Post by: Mark Strickland on April 14, 2006, 12:27:53 PM
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.
Title: What happens if (button push)?
Post by: TechSupport on April 14, 2006, 02:04:34 PM
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.