[fpc-devel] TCustomApplication
Henry Vermaak
henry.vermaak at gmail.com
Mon Aug 19 14:27:28 CEST 2013
On Mon, Aug 19, 2013 at 02:03:11PM +0200, Michael Schnell wrote:
> On 08/19/2013 01:47 PM, Michael Van Canneyt wrote:
> >
> >YOU DO NOT NEED TO DO THIS.
> >
> >Just implement the loop and let it call CheckSynchronize at
> >regular intervals.
> >All the rest will be done for you.
> >
> Did you ever do embedded software ?
>
> The result of the event in the main queue is not having something
> displayed to a human, but may be a command to the attached
> "machine", which might be really fast.
>
> Thus regular polling is an absolute no-go here.
>
> Doing the polling "slow" results in huge latency regarding the events.
>
> Doing the polling "fast" results in a huge processor overhead and
> thus in a huge overhead regarding anything else that the CPU is
> supposed to do.
You don't need to poll. Just make sure that you assign and implement
WakeMainThread (classes.pp). When Synchronize() is called, it will
check if WakeMainThread is assigned and call it. This will wake up your
main loop and you can then call CheckSynchronize().
How you implement WakeMainThread will depend on your event loop
mechanism. A simple way to do this is with the self-pipe trick.
Henry
More information about the fpc-devel
mailing list