[REBOL] Re: Aplication crashes - not sure why
From: james:mustard at: 14-Apr-2002 22:54
Sunanda wrote:
> Nice looking buttons!
Thanks ;-) They are temporary until I create aqua style glass buttons with
a greyscale effect.
> It's them waits in the action facets. You are creating simultaneous
threads
> and rebol don't like that much as yet.
>
Ah hah.. Bad design on my part.
> Check the list archives for subject "multiple threads crash". Holger wrote
in
> that thread:
<snip>
Hmm.. I am used to the VisualBasic/Access event model where i can use local
static variables within event handlers to act as blocks to avoid event
collisions.
eg:
sub event_ontimer()
static busy as boolean
if busy then exit sub
busy = true
... event code ...
busy = false
end sub
The waits were an attempt to stop repeated event firing - I assumed
(wrongly) that the event would be locked. Of course it wouldn't be on
hindsight and I would need to implement a blocker system like I
traditionally do in VB/Access.
As i was unsure how to apply static local variables in rebol (without
building objects to store them in..) I wrongly chose to use wait.
Perhaps it would just be tidier to build an object and store blocking flags
for each event...
> To handle that, you need a global variable that tells you if you have an
> action facet running. Check it at the start of every action. Return
> immediately if it is true, otherwise set it and continue. Remember to
unset
> it at all the return points or the whole application gets blocked.
I prefer localised blockers to avoid application lockup and easier
maintenance.
> 2. For good user relations (and the reason for wait 0 is), the user needs
a
> way to cancel a long-running action. My application (which looks similar
to
> your, but with less snazzy buttons) has a "Cancel button". If the user
clicks
> that, it sets a global "stop it" variable. Long-running action facets
check
> for this variable at regular intervals.
Hmm.. probably a good idea that - having a global die flag for action
handlers. Will give it a go.
Regards,
James