BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Using Threads

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage)
View previous topic :: View next topic  
Author Message
Steven Matrthews
Guest





PostPosted: Sat Jul 26, 2003 5:03 pm    Post subject: Using Threads Reply with quote




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 search functions
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


Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.