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 

How to use a TThread component...

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





PostPosted: Sat Dec 13, 2003 8:18 pm    Post subject: How to use a TThread component... Reply with quote



I am interested in using TThread to parse a text file and populate a
database table, is there anyone that can give me a few pointers as to how
this could be done? Also if there are any traps to watch out for?

Also, is it a good idea to handle exceptions within the thread?

Daryl




Back to top
nicolasr
Guest





PostPosted: Tue Dec 16, 2003 11:55 am    Post subject: Re: How to use a TThread component... Reply with quote



Hi,

just a few points:
Create a descendant of TThread, override the Execute() method.
In Execute() populate the database. Make sure that you check
the threads Terminated variable regularly such that the thread can
be stopped from outside if needed. If Terminated==true close all
open resources (files, database etc.) and leave Execute().
You probably want to show some progress status. Don't show a form
inside the thread! Instead create a form in the main thread and define
f.e. custom messages that the thread can post to the main thread via
PostMessage() such that the main thread will display the status form.

Catch exceptions inside your threads Execute().

hope this helps,
Nick

"Daryl" <stockd (AT) tpg (DOT) com.au> schrieb im Newsbeitrag
news:3fdb74db (AT) newsgroups (DOT) borland.com...
Quote:
I am interested in using TThread to parse a text file and populate a
database table, is there anyone that can give me a few pointers as to how
this could be done? Also if there are any traps to watch out for?

Also, is it a good idea to handle exceptions within the thread?

Daryl







Back to top
Rodolfo Frino - Macrosoft
Guest





PostPosted: Fri Dec 19, 2003 2:51 pm    Post subject: Re: How to use a TThread component... Reply with quote



Why not doing that directly with the win32 API's?

"Operating System: Bunch of software that makes your life easier by making
your system more difficult to understand". Rodolfo, 2003


"Daryl" <stockd (AT) tpg (DOT) com.au> wrote

Quote:
I am interested in using TThread to parse a text file and populate a
database table, is there anyone that can give me a few pointers as to how
this could be done? Also if there are any traps to watch out for?

Also, is it a good idea to handle exceptions within the thread?

Daryl







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.