[fpc-devel] Threads and alot of crap continued
mschnell at lumino.de
Tue Nov 7 15:47:25 CET 2006
> I can't call callbacks in threads? Why's that? Or am I understanding
> something wrong?
Of course you can use "events" (aka class properties that are functions)
in threads. That is just the Object Pascal syntax. But in the main
thread in Delphi or Lazarus events of GUI objects (e.g. TButtons) are
called "automatically" by user actions (thus in effect by hardware
events, which cause messages in Windows). This is not possible with
threads in Delphi, as system messages are sent to the main (GUI) thread
of a project. A thread can _programmatically_ wait for a message, but
the Delphi (and Lazarus) event scheduler that calls events of GUI based
objects only works for the main thread.
>> and if you go single-threaded you have to provide the main loop
> Do I? I always thought a timer is more comparable to an interrupt or
> signal than a polling loop.
In Delphi this is done by system messages, so no permanent polling
(spinning) but using a wait for message Windows API. I don't know how
this is done in Kylix or Lazarus/Linux.
> Well, for me it would have saved me some time which I wasted in creating
> threads that implement "timing events" by simply sleeping for a
> particular time.
IMHO this should be done following the Delphi paradigms to be nice to
Delphi users coming over to FCP (only enhancement allowed). Of course
Lazarus does this, but IMHO it would be great to have this in a system
without a GUI, too.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the fpc-devel