Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Pause and resume a thread in Qt
Forum Updated to NodeBB v4.3 + New Features

Pause and resume a thread in Qt

Scheduled Pinned Locked Moved General and Desktop
10 Posts 3 Posters 4.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    chcw
    wrote on last edited by
    #1

    In Qt, does it support to pause and resume a thread? Thanks

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andreyc
      wrote on last edited by
      #2

      Yes, Qt supports pause and resume a thread.

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        You'll have to be a bit more specific, what exactly do you mean by pausing and resuming a thread ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • C Offline
          C Offline
          chcw
          wrote on last edited by
          #4

          For example, after a thread is started for some time, I want to pause the execution of the thread codes for several minutes, and then resume the execution from the point where the thread is paused.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Then it's up to you to do the design of such a functionality using e.g. a QWaitCondition.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • C Offline
              C Offline
              chcw
              wrote on last edited by
              #6

              Is it possible to do not modify the internal codes of the thread, instead, just operate on the thread itself from outside to suspend and resume the thread.

              In Visual C++ and Windows system, it is possible to do so by calling:

              pThread->SuspendThread();

              and

              pThread->ResumeThread();

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Looks like some answers disappeared… Did you got the last one ?

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • C Offline
                  C Offline
                  chcw
                  wrote on last edited by
                  #8

                  No. Could you please rewrite again? Sorry about it but it seems a system problem?

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    If you are only targeting windows, then you can use native threads directly. Be aware that (AFAIK) posix threads don't have the concept of pause/resume.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0
                    • C Offline
                      C Offline
                      chcw
                      wrote on last edited by
                      #10

                      All my current threads are written via a QThread derived class, need I rewrite all of them to native versions, or is QThread providing an interface for me to access the Windows native thread wrapped by QThread? I think QThread is a wrapper of the underlying operating system native thread.

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved