canceling a "wait with messages" call...
andre at andregarzia.com
Fri Aug 31 11:32:25 CDT 2007
Thanks all for the messages!
What I am doing is mixing async and sync behaviors. I want the network
access to go async so that it doesn't block the ui or the application but I
want the handler that started the async call to be stopped while the
transaction is happening.
The script is a Bills of Materials processor that downloads files. To
simplify the script to the point where someone else than me (I write very
obscure scripts...) can actually understand what is happening, I've opted to
a structure like this:
libURLDownloadToFile tURL, tFile, "theCallback"
wait while lFileStatus is empty with messages
so what happens is that the handler above loads a file using an async call
but is blocked by the wait. The callback, when it occurs, set the local
variable to some non-empty value which thus unblock that wait call allowing
that handler to further process the files.
Some may ask, "why don't you do the further processing on the callback!?".
The answer for that is: "no." (sorry, prolog joke). The long answer is that
the solution above leads to scripts easier to maintain and easier to follow.
The good thing of using a script local variable as a flag allows me to have
other handlers doing side-effects. For example, I have my own timeout
handler that will set that flag to a non-empty-but-error value if libURL
really fails. The callback is only called by libURL, having a flag makes
easy to your code to interface with your async/sync blocking mechanism.
The trouble is, sometimes when I set that local variable to a non-empty
value, the handler does not unblock and that keeps me thinking: "why? oh why
my hanlder does not unblock when I set the very especific condition to it's
unblocking to true!?"
if there is no way to unblock that thing, then I want to finish/abort/kaput
it, which I guess I also can't do.
Dave, I got to waitdepth 6 using those handlers which got me thinking about
nested russian dolls blocking each other. Do you know if there's a way to
force a handler stopped on a wait call to resume or exit to top?
More information about the use-livecode