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 

TidThreadComponent and Free

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock
View previous topic :: View next topic  
Author Message
Jacky
Guest





PostPosted: Thu Apr 22, 2004 1:31 am    Post subject: TidThreadComponent and Free Reply with quote



Hi, i'm using TidThreadComponent as an internal field of my class.

TMyJob = class(TObject)
FThread: TidThreadComponent;
FClient: TidTcpClient;
...
...
end;

when i'm using this class like this :

var
MyJob: TMyJob;
begin
MyJob := TMyJob.Create();
try
CeoJob.StartJob;
// Sleep(5000)
finally
CeoJob.Free;
end;
end;

it calls TMyJob.Free before FThread finish it's work. When I give
enough time to finish it's work with adding Sleep(5000) line,
everything is ok. It's not a good way i know that so i wants to know
what is the solution of this problem.

- Jacky
Back to top
Jacky
Guest





PostPosted: Thu Apr 22, 2004 12:23 pm    Post subject: Re: TidThreadComponent and Free Reply with quote



I typed wrong. CeoJob should be MyJob. Sorry about it

Jacky wrote:

Quote:
Hi, i'm using TidThreadComponent as an internal field of my class.

TMyJob = class(TObject)
FThread: TidThreadComponent;
FClient: TidTcpClient;
...
...
end;

when i'm using this class like this :

var
MyJob: TMyJob;
begin
MyJob := TMyJob.Create();
try
CeoJob.StartJob;
// Sleep(5000)
finally
CeoJob.Free;
end;
end;

it calls TMyJob.Free before FThread finish it's work. When I give
enough time to finish it's work with adding Sleep(5000) line,
everything is ok. It's not a good way i know that so i wants to know
what is the solution of this problem.

- Jacky



Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Thu Apr 22, 2004 8:14 pm    Post subject: Re: TidThreadComponent and Free Reply with quote




"Jacky" <noname (AT) noname (DOT) com> wrote


Quote:
it calls TMyJob.Free before FThread finish it's work. When I
give enough time to finish it's work with adding Sleep(5000) line,
everything is ok. It's not a good way i know that so i wants to
know what is the solution of this problem.

Have you considered simply adding a destructor to TMyJob that stops the
thread and actually waits for it to fully terminate before then freeing it?


Gambit



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock 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.