#1 2017-12-02 10:01:54

RObyDP
Member
Registered: 2015-02-19
Posts: 62

System.Threading TThreadPool and TLS

sorry for the offtopic,
hello,
I'm using the very powerful TTASK api of System.Threading,
however I need a thing:
the pool is dynamic, I attach a TLS class with DB components into the running thread of the context, and keeping it in memory until the thread runs (avoiding create and destroy every time a db context).
I need to have an event OnAThreadExit of the System.TThreadPool so I can free the TLS class when the thread is made free.
How can be done without change the source of System.Threading.pas? Winapi doesn't offer a callback on thread exit, only a poll api is found, so cannot be used (I need to call TLS code within the thread, before the exit).

thank you
R.

Offline

#2 2017-12-02 20:42:36

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,206
Website

Re: System.Threading TThreadPool and TLS

Why are you asking this question here?
It depends on the Delphi RTL, not on mORMot.
You should better ask on stack overflow, I'm sure. wink

For the mORMot background process classes, there is are built-in events when the threads start or stop.

Offline

Board footer

Powered by FluxBB