[fpc-devel] Threads and alot of crap continued
Ales Katona
almindor at gmail.com
Tue Nov 7 16:17:00 CET 2006
> This is how lNet already works, no ? Where's the difference ?
Indeed but it's only there because there's no other way, if I could just
make it "magicly" work without "CallAction" I'd love to.
You can't call callbacks in threads (you can but only in one thread, not
between threads), and you can't magicly "jump into execution" if
something happens, with the exception of OS signals (which use a hack in
hardware afaik).
So eg: if you want to do something every 1000ms, you could put a TThread
based timer in, and make it Sleep(1000) and then call the code, but you
must be sure that your main thread cannot have conflicts if this code is
called at any time (eg: variable writes etc.).
My point was that making a non-blocking or blocking event based
main-loop-hooked mechanism for polling events is IMHO overkill in most
cases (there are obvious exceptions but they need obvious specifics
anyhow). It's easier for the user to simply check some times and see if
the interval is hit and then call the function in his main loop mostly.
IMHO ofcourse.
Ales
More information about the fpc-devel
mailing list