How to test if a thread has ended
Posted on 2005-04-14
I have a CWinThread derived class that I am using. Occationally while the thread is running I will post it thread messages using PostThreadMessage() which works fine. The object is deleted when the threads finishes the Run() function because I have set m_bAutoDelete = TRUE. However, if the thread ends before I expected it to, I get an error because I am trying to PostThreadMessage to an object that no longer exists.
How can I test to see if PostThreadMessage is going to cause an error because the object is deleted?