[Customdrawn] LazClock exercise

Giuliano Colla giuliano.colla at fastwebnet.it
Mon Apr 2 15:59:21 CEST 2012


Il 02/04/2012 15:36, Michael Schnell ha scritto:
> On 04/02/2012 03:03 PM, Felipe Monteiro de Carvalho wrote:
>> people should avoid depending on implementation details.
> That should be documented, at least :)
>
>> The only way to make it guaranteed would be to make it run the even on
>> another thread and make the timer completely threaded
> Throwing the TTimer event in a Thread is not at all what anybody would 
> want. This would ask for huge complexity in the user code.
>
It may (and should) be completely transparent.
It all depends on how it's implemented.
When you're using Qt widgetset (at least in Linux), what happens is more 
or less like that: the timer is handled in an appropriate thread, when 
it expires it sends a message which is received by the Qt loop, from 
there sent to the loop where the WaitMessage of the Lazarus Widgetset 
receives it from there used to inform the main loop which wakes up, and 
finally triggers the OnTimer event of your TTimer. (Rather inaccurate, 
but just to give the idea).

The result, as everything has been cleverly designed, that your OnTimer 
event triggers at the split millisecond. I don't know how many threads 
have been involved in all that, but, as long as it works, nobody cares. 
Most of all, the user doesn't have to worry about it. It's just a 
developer problem.

An OnClick event involves at least a couple more of threads, but you 
just see it as an event. The rest occurs behind the scenes.

Giuliano






More information about the Customdrawn mailing list