Article View: borland.public.cppbuilder.nativeapi
Article #5900Re: Check Thread State
From: Remy Lebeau (TeamB)
Date: Thu, 23 Jun 2005 22:59
Date: Thu, 23 Jun 2005 22:59
24 lines
1860 bytes
1860 bytes
"qyte" <gyte@vivodinet.gr> wrote in message
news:42bb2031$1@newsgroups.borland.com...
> if i have created a thread that in it's constructor method i have
> FreeOnTerminate=true; if i declare the TMyThread *MyThread;
> global is there a way of knowing if the thread still runs or if is has
> been terminated and therefore freed???
Assign NULL to your global pointer when the thread is terminating. Either
at the end of the thread's Execute() method, or better in the thread's
DoTerminate() method. The rest of the code can then check for NULL when
needed. You have to be careful, though, because if you are going to access
the thread after checking for it, it may disappear after the check but
before the access, ie:
if( MyThread ) // <-- thread is still running
{
// thread terminates here...
MyThread->DoSomething(); // <-- now an invalid operation
}
Gambit
Technical Details
Message-ID:
<42bb3f9c$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news2.google.com!proxad.net!212.101.4.254.MISMATCH!solnet.ch!solnet.ch!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<42bafc6d$1@newsgroups.borland.com> <42bb04df$2@newsgroups.borland.com> <42bb2031$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,d956c8a88fce8455 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <42bafc6d$1@newsgroups.borland.com> <42bb04df$2@newsgroups.borland.com> <42bb2031$1@newsgroups.borland.com> Subject: Re: Check Thread State Date: Thu, 23 Jun 2005 15:59:26 -0700 Lines: 26 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 68.69.17.41 Message-ID: <42bb3f9c$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1119567772 68.69.17.41 (23 Jun 2005 16:02:52 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news2.google.com!proxad.net!212.101.4.254.MISMATCH!solnet.ch!solnet.ch!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail