I have a thread called elab.
Doing step by step debugging and using Ctrl-Alt-T thread window I see that after:
elab.free;
my thread is still alive.
So after some time there are too many threads and the application crashes.
The same with elab.destroy; or FreeAndNil(Elab);
When I try to free my thread it has already finished its execute function and I have just to read some variables and kill it.
Instead if I use the windows API:
TerminateThread(Elab.Handle, 0);
CloseHandle(Elab.Handle);
the threads are correctly destroyed and the application runs but I have to disable debugger because it says that it cannot read PC registry.
How could I destroy a thread using lazarus functions?