How to close Joinable threads
Posted: Mon Aug 17, 2009 2:43 pm
Trying to close the GUI application immediately after calling the close function of the UDP thread.
GUI application is crashed. After debugging
My close function which is called in the destructor of the UDPMessageThread class
Please someone help me how to delete or close the Joinable thread and immediately closing the main application?
GUI application is crashed. After debugging
Code: Select all
BugReporter.exe!wxMutexInternal::LockTimeout(unsigned long milliseconds=0xffffffff) Zeile 232 + 0x7 C++
BugReporter.exe!wxMutexInternal::Lock() Zeile 190 + 0x11 C++
BugReporter.exe!wxMutex::Lock() Zeile 45 C++
BugReporter.exe!UDPMessageThread::close() Zeile 95 C++
BugReporter.exe!UDPMessageThread::~UDPMessageThread() Zeile 75 C++
BugReporter.exe!UDPMessageThread::`scalar deleting destructor'() + 0x14 C++
BugReporter.exe!BugReporterApplication::stopUDPThread() Zeile 1697 + 0x25 C++
wxMutexError wxMutexInternal::LockTimeout(DWORD milliseconds)
{
--> DWORD rc = ::WaitForSingleObject(m_mutex, milliseconds);
if ( rc == WAIT_ABANDONED )
{
Code: Select all
void UDPMessageThread::close()
{
d_accessDataMutex.Lock();
d_run=false;
d_accessDataMutex.Unlock();
// Wait till thread deletes itself
ExitCode exitCode ;
if (IsRunning())
{
exitCode = Wait();
cout << "exit code: " << exitCode << endl;
}
d_accessDataMutex.Lock();
if (d_socket!=NULL)
{
d_socket->Destroy();
d_socket=NULL;
}
d_accessDataMutex.Unlock();
}