[fpc-devel] Threads and alot of crap continued

Ales Katona almindor at gmail.com
Tue Nov 7 13:42:37 CET 2006

I'm not sure I see the value behind these ideas.

If you need an event-based loop and callbacks you can make TApplication. If
you don't want LCL ok, then make your own, it's generaly needed to be very
problem-specific anyhow, eg: the TLEventers I use are ment for handling
events on handles (files and sockets atm, sockets only in windows).

If you want a "Timer" a "polling" mechanism has to take place which looks if
something happened on some timer for example, OnTimer is "ready to be fired"
(you can't call callbacks in threads, and if you go single-threaded you have
to provide the main loop hooks).

So basicly, let's say TTimer is in RTL and there's some event mechanism
already too, you'd have to do something like this:

procedure init;
  EventHandler.RegisterTimer(Timer); // could be the other way around

procedure MainLoop;
  EventHandler.HandleEvents; // if eventhandler after polling all timers in
it's watchlist find out some has it's interval done, it fires it's callback


Apart from asynchronous stuff like watching handles etc. I don't see much
use for this relativly complicated program model. Remember you need to call
the "HandleEvents" as fast as possible to stay effective (otherwise you lose
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20061107/9aed7b06/attachment.html>

More information about the fpc-devel mailing list