Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the purpose of TThread.FinishThreadExecution, and when is it called?

I've been trying to implement a thread that runs in the background and updates a progress bar every second or so and following the example in the top answer to Delphi - timer inside thread generates AV. I notice that the proposed solution has an implementation of TThread.FinishThreadExecution. My IDE shows that my version of delphi supports that method, but I've been unable to find any documentation on it (google turns up 10 hits, none of which help, http://docwiki.embarcadero.com/ doesn't list that method under TThread. What is it for and when is it called?

like image 629
user2983114 Avatar asked Mar 21 '23 16:03

user2983114


1 Answers

FinishThreadExecution is not a method inherited from the TThread base class. It is only a method implemented in the derived class, TTimerThread.

The purpose of the method is to finish the execution of the thread in a proper way.

All FinishThreadExecution does is to call Terminate, which sets an internal flag in the TThread, plus sets the FTickEvent event to wake the thread. The thread execute method will then end and the thread will self destruct, since TThread.FreeOnTerminate is true.

like image 93
LU RD Avatar answered Apr 27 '23 22:04

LU RD