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 

Time to launch a thread?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (Multi-Tier)
View previous topic :: View next topic  
Author Message
John Ullom
Guest





PostPosted: Mon Feb 27, 2006 8:03 am    Post subject: Time to launch a thread? Reply with quote



Hi All,

I am a mid grade coder wanna be. I am wondering if the situtaion implied by the following code listings would be a good place to launch a TThread.

Here are three procedures:

function TCoolCode.GetNextID : integer;
begin
DataSetStoredID.First;
GetNextID := CDSSToredID.FieldByName('ID').AsInteger;
DataSetStoredID.Delete;
DataSetStoredID.Post;
CheckIDCount;
end;

procedure TCoolCode.CheckIDCount;
begin
if DataSetStoredID.RecordCount < 100 then
begin
GetABunch; // Launch In Thread??
end;
end;

procedure TCoolCode.GetABunch; //Threaded??
begin
DataSetAddID.Close
DataSetAddID.Param[0].AsInteger := 1000;
DataSetSAddID.Open;
DataSetStoredID.Add(DataSetAddID.Data);//Psudo psudo code
end;

When Client starts it check to see if it has a saved copy of DataSetStoredID. If not it calls GetABunch; When Client closes it saves a copy pf DataSetStoredID.

When the Client needs a RecordID for a new record it calls GetNextID. If the DataSetStoredID.RecordCount drops below 100, GetABunch is called and adds 1000 records/IDs to DataSetStoredID.

Can I launch GetABunch in a TThread?

Would you launch GetABunch in a TThread?

Should I launch GetABunch in a TThread?

Or will a TThread leave my application dead?

I think enough said, I'm going to bed!

Thanks!

John Ullom

PS Is the poor attempt at poetic posting appreciated or is it bad form?
Back to top
Erick Sasse
Guest





PostPosted: Mon Feb 27, 2006 1:03 pm    Post subject: Re: Time to launch a thread? Reply with quote



John Ullom wrote:

Quote:
DataSetStoredID.Delete;
DataSetStoredID.Post;

Is this code working? You can't post after a delete, since your dataset
won't be in insert or edit state.

--
Erick Sasse
Brazil
Back to top
Craig Stuntz [TeamB]
Guest





PostPosted: Mon Feb 27, 2006 5:03 pm    Post subject: Re: Time to launch a thread? Reply with quote



John Ullom wrote:

Quote:
Should I launch GetABunch in a TThread?

No. The time to consider putting something in a thread is *after* it
has been optimized, not before. Putting something in a thread will not
make it run faster -- it may in fact make it slower -- and will
introduce a number of complications, such as the fact that many Delphi
DB components and some DB servers require a separate connection for a
concurrent thread. If your process is slow, use a profiler to identify
the slowest part and fix it.

--
Craig Stuntz [TeamB] · Vertex Systems Corp. · Columbus, OH
Delphi/InterBase Weblog : http://blogs.teamb.com/craigstuntz
Want to help make Delphi and InterBase better? Use QC!
http://qc.borland.com -- Vote for important issues
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (Multi-Tier) 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.