Re: is thread still running

Tech-Archive recommends: Fix windows errors by optimizing your registry



On Tue, 17 May 2005 07:06:17 +0200, z f wrote:

> ok,
>
> then how do i destroy the instance created with AfxBeginThread?

http://groups-beta.google.com/group/microsoft.public.vc.mfc/msg/10f8a2138b08f866?hl=en
<q>
If you set m_bAutoDelete to false, you assume the
responsibility for deleting the CWinThread,
</q>

So, you would do something like this (pseudocode):

pThread = AfxBeginThread(...CREATE_SUSPENDED...);
pThread->m_bAutoDelete = false;
pThread->ResumeThread();
....
WaitForSingleObject(pThread->m_hThread, INFINITE);
....
delete pThread;

--
Doug Harrison
Microsoft MVP - Visual C++
.



Relevant Pages

  • Re: Aggregation vs composition
    ... responsibility is shared because the object is shared. ... Is this not Composition, simply because Car is ... may destroy the part. ... >> other language that I'm aware of. ...
    (comp.object)
  • Re: Aggregation vs composition
    ... and as composition is transitive, the engine is part of Car, too. ... remove them) can be taken in responsibility for destroying them. ... >>This applies to every language where the programmer has full control on ... In a language, where one can destroy objects explicitly, it's not a big ...
    (comp.object)
  • Re: False rape accusation & misplaced chivalry
    ... by a lying tart. ... She didn't destroy the life of ... He bears full responsibility for ... Just because radical feminists blame men for all the ridiculous things ...
    (soc.men)
  • Re: is thread still running
    ... then how do i destroy the instance created with AfxBeginThread? ... > After you set m_bAutoDelete to false, you will own the CWinThread object, ... > You can also use the GetExitCodeThread function, ...
    (microsoft.public.vc.mfc)
  • Re: Aggregation vs composition
    ... implementation level) you aren't able to destroy an object like in Java. ... But that doesn't change the semantics. ... > has sole responsibility for its own destruction, ... and aggregation are implemented often in the same way. ...
    (comp.object)