wxThread termination not recognized

Fabian Cenedese Cenedese at indel.ch
Wed Jun 27 08:10:33 PDT 2007


Hi

I'm with wxMSW 2.8.0 on Windows XP, MSVC6.

I have a problem with termination of a thread. It's basically this code
in app::OnInit():

------------------------
m_pThread=new wxThread(wxTHREAD_JOINABLE);
if (m_pThread->Create()!=wxTHREAD_NO_ERROR) {
	return false;
}
m_pThread->Run();

// 1. this works
CIOUUWizard* wizard=new CIOUUWizard(0, NULL);  // derived from wxWizard
wxDELETE(wizard);

// 2. this doesn't work
CIOUUWizard wizard(0, NULL);

m_pThread->Delete();
m_pThread->Wait();
wxDELETE(m_pThread);
------------------------

The thread always polls TestDestroy().

If I create and destroy the wxWizard dynamically the thread gets stopped
and Delete() returns. But if I use the second variant Delete() stops the
thread (verified with breakpoints and MSVC thread list) but it never
returns anymore. It loops endlessly in wxThreadInternal::WaitForTerminate.
::MsgWaitForMultipleObjects always returns 1 though m_state is
STATE_EXITED.

Does this have to do with the message loop of the wxWizard? Do I have
to delete the wizard completely even if the frame is not shown?

Thanks

bye  Fabi






More information about the wx-users mailing list