if ( shouldResume )
Resume();
- // does is still run?
+ // is it still running?
if ( isRunning || m_state == STATE_RUNNING )
{
if ( wxThread::IsMain() )
if ( pRc )
*pRc = rc;
+ // we don't need the thread handle any more
+ Free();
+
+ wxCriticalSectionLocker lock(critsect);
+ SetState(STATE_EXITED);
+
return rc == (wxThread::ExitCode)-1 ? wxTHREAD_MISC_ERROR
: wxTHREAD_NO_ERROR;
}
return ::GetCurrentThreadId() == gs_idMainThread;
}
-#ifdef Yield
-#undef Yield
-#endif
-
void wxThread::Yield()
{
// 0 argument to Sleep() is special and means to just give away the rest of
(void)m_internal->WaitForTerminate(false, m_critsect, &rc);
- m_internal->Free();
-
- wxCriticalSectionLocker lock(m_critsect);
- m_internal->SetState(STATE_EXITED);
-
return rc;
}
wxThreadError wxThread::Delete(ExitCode *pRc)
{
- wxThreadError rc = m_internal->WaitForTerminate(true, m_critsect, pRc);
-
- if ( IsDetached() )
- {
- delete this;
- }
- else // joinable
- {
- // update the status of the joinable thread
- wxCriticalSectionLocker lock(m_critsect);
- m_internal->SetState(STATE_EXITED);
- }
-
- return rc;
+ return m_internal->WaitForTerminate(true, m_critsect, pRc);
}
wxThreadError wxThread::Kill()