Search code examples
c++multithreadingwxwidgets

wxWidgets wxThread Delete for a Joinable Thread


I got a question about joinable threads in wxWidgets.

When the user wants it, I want to stop a thread doing some work. For that reason I call in this worker thread TestDestroy() to check whether the thread should be stopped. But I can only stop the thread this way by calling Delete(), which should not be called for joinable threads.

Is there a possibility for me to stop the thread (using TestDestroy) or do I have to change my code completely?

Thanks in advance,

TiBo


Solution

  • The current documentation for wxThread::Delete() says:

    This function works on a joinable thread but in that case makes the TestDestroy() function of the thread return true and then waits for its completion (i.e. it differs from Wait() because it asks the thread to terminate before waiting).

    So, it appears that you can use Delete() on a joinable thread.