Hello All,
I am learning how to use the TThread class to create
another thread from my mainform. Essentially, I am writing
a file/folder search program that uses a recursive function
called vSearch_Folder( ....) which takes 4 parameters. I am calling
this function within the Execute method of the thread object, using
the code below:-
void __fastcall searchThread::Execute()
{
FreeOnTerminate = false;
// call recursive search function
mainform->vSearch_Folder(THREAD_FolderPath,
THREAD_SearchString,
THREAD_iSwitch,
pTHREAD_iCounter);
// free up memory for thread object
FreeOnTerminate = true;
}
I am using a flag, FreeOnTerminate, to determine when the thread
has finished execution. (ie when the recursive function has finished.)
THe value of this flag is determined in mainform by calling inline
bool bGetThreadStatus(void){return FreeOnTerminate;};
which is declared in the class derived from TThread.
Q. Is there a better way to determine when a thread finishes execution ?
Thanks,
bigSteve