Problem with derived ~wxThread() Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Tapsa
Earned some good credits
Earned some good credits
Posts: 144
Joined: Tue Dec 06, 2011 5:52 pm
Location: Helsinki

Problem with derived ~wxThread()

Post by Tapsa » Wed Feb 17, 2016 2:42 pm

I followed the wxThread example in here:
http://docs.wxwidgets.org/trunk/classwx_thread.html
I made my own class that inherits wxThread, but its destructor is never executed.

Code: Select all

~MyThread();

Code: Select all

MyThread::~MyThread()
{
    ... // Set the thread pointer of my frame to 0 so I can check if this thread is executing or not.
}
I can see the exit code appear in command prompt and my queued event ( = what to do after completion) executes as it should.
I'm worried that the wxThread objects pile up over time and never die.
My thread calls this in its constructor:

Code: Select all

wxThread(wxTHREAD_JOINABLE)
What have I missed and how do I ensure that threads get destructed?

EDIT: Had to create the threads as detached.

Post Reply