cannot trust first beeps

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: heatherlaine, Klaus, FourthWorld, robinmiller, kevinmiller

Post Reply
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5379
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

cannot trust first beeps

Post by dunbarx » Tue May 22, 2018 5:49 pm

This has been going on forever.

In a button script:

Code: Select all

on mouseup
   startTimer
end mouseup

on startTimer
   if the optionKey is down then exit to top
   beep 2
   send "startTimer" to me in 60
end startTimer
Works fine, but each time the process is initiated in a new LC session (and sporadically in an existing session) the very first pair of beeps are delivered much more quickly than all subsequent ones.

Any else seen this? It could be a problem, I suppose, in certain circumstances

Craig

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5960
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: cannot trust first beeps

Post by FourthWorld » Tue May 22, 2018 6:23 pm

Timers are sent when idle happens; processing queues may stall a timer in a single-thread program like LC, causing them to batch up and fire more rapidly than expected.

To prevent that I usually check for existing instances of a given timer message before queuing more, e.g.:

Code: Select all

on startTimer
   if the optionKey is down then exit to top
   if "startTimer" is not in the pendingMessages then
      beep 2
      send "startTimer" to me in 60
   end if
end startTimer
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5379
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: cannot trust first beeps

Post by dunbarx » Tue May 22, 2018 7:19 pm

Richard.

Makes sense. Thanks.

Craig

Post Reply

Return to “Talking LiveCode”