Closed Gronfi closed 10 years ago
Use the TLKThread.Kill; method to destroy an active looping thread.
The .Free method of TLKThread works exactly the same way as that of TThread, the same precautions apply.
I cannot make TLKThread.Destroy call Terminate and WaitFor because the developer may already have called these themselves externally from the Thread, which would cause an error.
This is "Works as Designed", not a bug
Ok
Hi! I think the destruction of the basic thread must have a different order. Now: destructor TLKThread.Destroy; begin FLock.Free; inherited; end;
But, if you want to finish a thread, and you don't terminate it before calling the destroy, you can have issues with the FLock variable. Why? Because in the loop execution that variable is accesed and you get access violations sometimes (depends where the lopp is in that momment) because the variable is free, but the loop not ended until the inherited sentence finishes it. Hope I explained the case. The solution is easy, change the order of destruction: destructor TLKThread.Destroy; begin inherited; FLock.Free; end;
Let me know what you think. Regards