On Tue, 21 Dec 2010, Mattias Gaertner wrote:
On Tue, 21 Dec 2010 14:29:36 +0100 (CET)
michael.vancann...@wisa.be wrote:
On Tue, 21 Dec 2010, Mattias Gaertner wrote:
Hi,
How to get the current TThread instance?
There is no documented method.
Strange.
Am I really the first needing this?
Apparently.
I never needed such a method, and I use threads extensively :-)
For example: I created a TThread and called a function, which calls a
function .... One of those sub functions needs to call
TThread.Synchronize, which needs as parameter the current TThread.
Pass on the TThread instance.
You mean as parameter?
Yes.
Some functions are predefined events. That means I call them and they
call me back. I would like to avoid adding everywhere another parameter.
I understand that. Well, you could create an event object for the event
handler.
You could use GetCurrentThreadID and a lookup list.
What about using a
threadvar CurrentThread: Thread;
?
TThread could set this in the constructor.
This could be done, but will give errors for externally created threads.
But you can easily do this for your own thread objects.
BTW, you can call Synchronize for another thread than the current.
Is that allowed?
It's a method like any other. Why not ?
Michael.
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal