How to use "send"
Dar Scott
dsc at swcp.com
Tue Jun 10 14:36:20 EDT 2003
On Tuesday, June 10, 2003, at 01:00 PM, Shao Sean wrote:
> i know i was doing some heavy looping using the "send"
> command and it would stop whenever the app would go into the
> background, but sometimes the "send" command would be
> skipped (it was doing every second "send" command).. i found
> adding "wait for 1 millisecond" after the "send" command
> made everything work fine (could background and all the
> "send"s were issued)..
>
> Win95, Win2000Pro
> RunRev 1.1.1, RunRev 2
I'm putting together a tiny primer on using send. If I can verify
this, I'd like to pass on the warning. Do you have a simple script or
stack that illustrates this?
I have seen some engine or OS housekeeping work done at certain times
such as in a wait. Also, if you keep the pendingMessages cluttered
with ready-to-run messages you will not get events processed. Perhaps
the problem you have seen is related to these. Maybe when the app was
in the background the messagePending queue filled up faster than it
emptied.
There are a few things that can be done to keep messages from swamping
an application. When starting a state machine, test whether it is
already going and either let it be or stop it and then restart it.
When the period is not critical in sending to self, send at the end of
the handler, not at the front. If the period is critical, then keep it
and all message handlers fast. When using read from socket ... with
message, consider a way to choke the messages, perhaps by having the
read send a delay before the next read.
Dar Scott
More information about the use-livecode
mailing list