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. using 2 event loops in same thread

using 2 event loops in same thread

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 4 Posters 2.6k Views
  • 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.
  • R Offline
    R Offline
    rahush
    wrote on last edited by
    #1

    Hi,
    I am using 2 event loops in the main thread and my app is getting crashed. Is it possible to use two event loops in a same thread simultaneously? Is there any problem in using multiple event loops in same thread?

    Thanks..

    jsulmJ 1 Reply Last reply
    0
    • R rahush

      Hi,
      I am using 2 event loops in the main thread and my app is getting crashed. Is it possible to use two event loops in a same thread simultaneously? Is there any problem in using multiple event loops in same thread?

      Thanks..

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @rahush Didn't you already asked exact same question before?
      Why do you need more than one event loop?
      You cannot have more than one event loop running at exact same time - the last one started will block all other.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      R 1 Reply Last reply
      2
      • jsulmJ jsulm

        @rahush Didn't you already asked exact same question before?
        Why do you need more than one event loop?
        You cannot have more than one event loop running at exact same time - the last one started will block all other.

        R Offline
        R Offline
        rahush
        wrote on last edited by
        #3

        @jsulm
        Thanks, I have one more doubt. Is there any possibility of app crash in this case?

        jsulmJ 1 Reply Last reply
        0
        • BjornWB Offline
          BjornWB Offline
          BjornW
          wrote on last edited by
          #4

          Why do you want to have two loops? What is the use case? It sounds like you're doing something wrong.

          R 1 Reply Last reply
          0
          • BjornWB BjornW

            Why do you want to have two loops? What is the use case? It sounds like you're doing something wrong.

            R Offline
            R Offline
            rahush
            wrote on last edited by rahush
            #5

            @BjornW
            Thanks @BjornW , I can explain you the use case. There are two instances where I am using event loops.
            There is an event loop in the main thread of the application where I am handling the events. Along with this I am sending some metrics to a remote URL(say once every hour), so sending metrics is a background job. I am sending the metrics using QNetworkAccessManager. You can refer this topic for the code: https://forum.qt.io/topic/77972/desktop-app-crashed-when-2-event-loops-are-used .
            The event loop used in the topic link above is getting failed.

            1 Reply Last reply
            0
            • R rahush

              @jsulm
              Thanks, I have one more doubt. Is there any possibility of app crash in this case?

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @rahush Second event loop alone should not crash you app. I think you're doing something wrong.

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • BjornWB Offline
                BjornWB Offline
                BjornW
                wrote on last edited by
                #7

                You should really keep this in a single forum thread. I will reply in one you linked.

                1 Reply Last reply
                0
                • VRoninV Offline
                  VRoninV Offline
                  VRonin
                  wrote on last edited by
                  #8

                  Locked, continue in https://forum.qt.io/topic/77972/desktop-app-crashed-when-2-event-loops-are-used please

                  "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                  ~Napoleon Bonaparte

                  On a crusade to banish setIndexWidget() from the holy land of Qt

                  1 Reply Last reply
                  1

                  • Login

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