Two handlers sharing time

Scott Rossi scott at tactilemedia.com
Tue Dec 18 15:45:01 EST 2001


Recently, Shari wrote:

> Is it possible to have handlers share time?  So that when it is idle,
> the second handler runs?
> 
> I have a very lengthy handler, that does certain things, calls other
> handlers, and they in turn call other handlers.  This sets up the
> data for the user.
> 
> As it takes more than a few seconds, I've created things for the user
> to "do" while waiting.
> 
> Is there a built in way for the main handler that sets up the data,
> to pause if the user wants to do something while it's running?  And
> then start back up where it left off the minute the user isn't doing
> anything?

I don't believe MC permits simultaneous running of multiple scripts.

That being said, some events can be run while other messages are processed.
Wait and move are a couple of examples.

  wait until x = 5 with messages
 
  move grc 1 rel 0,100 without waiting

One way to do what you want might be to place "checkpoints" in your main
handler to check for activity or property/variable change in the second
handler.  A simple example:

# IN THE STACK...
on mainHander
  attentionCheck
  #doStuff1
  #doStuff2
  attentionCheck
  #doStuff3
  #doStuff4
  attentionCheck
  #doStuff5
  #doStuff6
end mainHandler

on attentionCheck
  if the userNeedsAttention of me then \
     wait until not the userNeedsAttention of me with messages
end attentionCheck


# IN A BUTTON OR OTHER CONTROL ACCESSIBLE BY THE USER...
on mouseDown
  set the userNeedsAttention of this stack to true
  # doUserStuff
end mouseDown

The efficiency of this may be questionable depending on what's being
processed.  It would help to know what you're doing when setting up data
that takes long enough to justify preoccupying the user.

Regards,

Scott

_____________________________________________________________________
Scott Rossi                       Tactile Media - Multimedia & Design
Creative Director                 Email: scott at tactilemedia.com
                                  Web: http://www.tactilemedia.com




More information about the metacard mailing list