Killing all threads when closing program
Unsolved
General and Desktop
-
wrote on 16 Jan 2018, 22:22 last edited by
Is there a way to kill all of the living threads when closing a program?
-
wrote on 17 Jan 2018, 04:03 last edited by
A signal that the application is shutting down, DTOR's, ThreadPools, WorkerThreads...
Without knowing your setup and even if I did know... I'm just going to say err yes?
Was there a specific case you were thinking / up against?
-
@michalt38
hi, closing a program implicates the termination of all threads. Am I right in assuming, you want to stop all threads when the UI is closed?You can do a Signal/Slot connect when you create the thread to a complish that:
QObject::connect(qApp, &QCoreApplication::aboutToQuit, myThread, &QThread::quit);
or if your QThread is a class member you can handle that in the destructor:
myClass::~myClass(){ myThread->quit(); myThread->wait(); }
1/3