Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

delete/close qtconcurrent thread pool



  • how would i close/delete the thread pool after finish running

    QFuture<void> future = QtConcurrent::run(...);

    for example one of my sub window GUI are running in qthread pool, but once i close that window, how do i destroy that qthread pool. some kind signal slot ?

    is there anyway to assign an id to thread pool?


  • Lifetime Qt Champion

    Hi,

    Do you mean cancel current request and delete the pool ?

    By the way, why are you running GUI elements in your loop ?


  • Moderators

    @s002wjh said in delete/close qtconcurrent thread pool:

    how would i close/delete the thread pool after finish running

    QFuture<void> future = QtConcurrent::run(...);

    Thread pools are designed to last a long time; they are not designed to be closed/deleted.

    You don't need to do anything after you finish with QtConcurrent::run().

    for example one of my sub window GUI are running in qthread pool

    Qt does not allow GUIs to be run in a secondary thread. All GUI classes must be accessed from the GUI thread, which is the thread which created QGuiApplication/QApplication.



  • @SGaist said in delete/close qtconcurrent thread pool:

    Do you mean cancel current request and delete the poo ?

    Probably an unfortunate turn of phrase... ;-)


Log in to reply