[fpc-pascal] Current TThread
Mattias Gaertner
nc-gaertnma at netcologne.de
Tue Dec 21 14:47:57 CET 2010
On Tue, 21 Dec 2010 14:29:36 +0100 (CET)
michael.vancanneyt at 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?
> > 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?
Some functions are predefined events. That means I call them and they
call me back. I would like to avoid adding everywhere another parameter.
> You could use GetCurrentThreadID and a lookup list.
What about using a
threadvar CurrentThread: Thread;
?
TThread could set this in the constructor.
BTW, you can call Synchronize for another thread than the current.
Is that allowed?
Mattias
More information about the fpc-pascal
mailing list