[Gambas-user] Using a timer and Last

Benoît Minisini gambas at ...1...
Sat Jan 1 16:06:12 CET 2011


> richard terry ha scritto:
> > Hi List
> > 
> > I've a couple of timers on different forms, which I need to auto-update
> > some stuff periodically.
> > 
> > What's the theory with Last and timers.
> > 
> > for example say my program is executing a subroutine which uses Last, but
> > at that instance the timer fires and becomes Last, can things go wrong?
> > 
> > Can just the Public = False property of the timer, mean it then cannot be
> > the Last event to fire?
> 
> Hi Richard, happy new year.
> 
> I think that there is no need to worry: a timer event is just as any
> other one, only it is fired without user intervention.
> 
> There is a single internal main loop, in gambas, which collects events
> and dispatches them, one at a time, to the relevant handler. Just before
> invoking the handler, the LAST variable is set. A gambas subroutine is
> never interrupted, so the LAST variable remains untouched (unless you
> modify it yourself). To be more precise, the LAST variable is saved (in
> a stack, I believe), then set to the relevant value, then the handler is
> called, then LAST is restored. As long as you avoid to use WAIT, nothing
> can corrupt LAST (apart from your own program). The fact that LAST is
> saved onto a stack, and restored afterwards, should keep you safe even
> when you use WAIT in a handler.

Yes, that's it. In Gambas 3 for sure. I don't remember if the value of LAST is 
saved before calling an event handler in Gambas 2...

> 
> About the Public property, I don't understand. The meaning of "Public"
> should only be relevant to the compiler, not to the runtime - "Public"
> should not be a property, but simply a declarative switch. May be that
> gambas uses the properties mechanism for simplicity, in order to allow
> you to declare something public using the GUI.

In Gambas, "Public" is a runtime thing too: it allows a symbol to be visible 
to the other classes, by putting inside the symbol table of the class. 
(Private symbols are private, so they do not need a symbol table at runtime, 
and so they are not visible to the other classes).

"Public" applied to a variable has nothing to do with events otherwise.

Regards,

-- 
Benoît Minisini




More information about the User mailing list