Possible help for extra-time-consuming operations?
J. Landman Gay
jacque at hyperactivesw.com
Sat Apr 16 15:14:06 EDT 2016
On 4/15/2016 8:25 PM, Quentin Long wrote:
> Have pondered the issue of ensuring that the OS does*not* label a
> seemingly-'frozen' LC app as unresponsive. The following code (which
> I haven't actually tried in LC, shame on me) might be helpful. Some
> notes after the code…
>
> ========================
>
> local KeepMeAlive = false
> local NumSecs = 4
>
> on LifeLine DerStatus
>
> case DerStatus = "on"
> put true into KeepMeAlive
> TickleMe
> break
>
> case DerStatus = "off"
> put false into KeepMeAlive
> break
>
> default
> exit to top
> end case
>
> end LifeLine
>
> on TickleMe
> if KeepMeAlive = true then send "TickleMe" to me in NumSecs seconds
> end TickleMe
>
> ========================
How great to see you on the list! Been a while.
I'm afraid the technique won't work though. The first "tickleMe" will
trigger when the local is set to "on" but after that a long handler
won't return control to the queue until it finishes, so any pending
"tickleMe" messages won't execute until the long handler is finished.
The fix is to wait 0 with messages inside the long handler, which yields
time to the engine and allows LC to do housekeeping. That works best
inside a repeat loop, otherwise it gets iffy.
--
Jacqueline Landman Gay | jacque at hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
More information about the use-livecode
mailing list