[Lazarus] TFPTimer, Linux

Antonio Fortuny a.fortuny at sitasoftware.lu
Fri Jan 17 15:56:57 CET 2014

> DaemonApp works using threads.
> TFPTimer is not usable in threads other than the main thread.
Right. So I made my own Timer based on the TFPTimer. Almost the same 
code except that the Synchronize(@EventProc) disapeared in my code and 
the EventProc is called immediately.
Another little feature is that the high level enable disable sequences 
do not kill the thread: using a TEvent and some lines of cole solves 
this problem whithout requiqring lots of CPU processing time. Even in in 
the worst case the thread will respond within 500 ms
Yes, I know, but what if more than one thread calls the same procedure ?
Well, it is not even protected by a critical section because based on a 
single rule: one Timer one procedure, nothing less nothing more. As a 
consequence I consider that the event procedure is part of the Timer 
object but only connected at runtime.
In a test GUI application, my timer runs perfect in a multi-threaded 
environment (one timer, one thread embedded into an object). My only 
little disappointment is that the timer precision goes from -5 to +5 ms.
But this doesn't bother me as my timers deal with tens (and more 
hundreds) of ms. So I consider that this little error isn't worth 
writing of code to get rid of it. I don't think that the world will stop 
turning around itself because a lack of 5 ms.


> Michael.
> --
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Ce courrier électronique ne contient aucun virus ou logiciel malveillant parce que la protection avast! Antivirus est active.

More information about the Lazarus mailing list