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. How to manage resources in thread without blocking main GUI thread ?
Qt 6.11 is out! See what's new in the release blog

How to manage resources in thread without blocking main GUI thread ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 472 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.
  • Q Offline
    Q Offline
    Qt embedded developer
    wrote on last edited by Qt embedded developer
    #1

    I have application which collect data from resource using thread.

    This collected data i am showing on main GUI thread.

    i want to know

    1. how to manage resources in thread so that it will not block the main GUI thread ?

    2. how to manage resources into thread so that it can not cause the crash ?

    3. how to send collected data of thread to main gui thread ?

    i have seen that my data collection thread is causing the random crash.

    jsulmJ 1 Reply Last reply
    0
    • Q Qt embedded developer

      I have application which collect data from resource using thread.

      This collected data i am showing on main GUI thread.

      i want to know

      1. how to manage resources in thread so that it will not block the main GUI thread ?

      2. how to manage resources into thread so that it can not cause the crash ?

      3. how to send collected data of thread to main gui thread ?

      i have seen that my data collection thread is causing the random crash.

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

      @Qt-embedded-developer

      1. Why should resources handled in another thread block the UI thread?
      2. As silly as it may sound: write correct code
      3. As most of the time with Qt: using signals/slots

      "i have seen that my data collection thread is causing the random crash" - as always in such situation: use debugger to get the stack trace and see where exactly it is crashing.

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

      Q 1 Reply Last reply
      1
      • jsulmJ jsulm

        @Qt-embedded-developer

        1. Why should resources handled in another thread block the UI thread?
        2. As silly as it may sound: write correct code
        3. As most of the time with Qt: using signals/slots

        "i have seen that my data collection thread is causing the random crash" - as always in such situation: use debugger to get the stack trace and see where exactly it is crashing.

        Q Offline
        Q Offline
        Qt embedded developer
        wrote on last edited by
        #3

        @jsulm

        for 2nd point. my thread is collect the multiple command response in this thread if i use mutex lock then it can miss the other commands from resource.

        So in this type of situation what is better way to mange response commands in collection thread.

        i know the threading. but i not know how manage the resources. for that which concept help so it not block or crash.

        jsulmJ 1 Reply Last reply
        0
        • Q Qt embedded developer

          @jsulm

          for 2nd point. my thread is collect the multiple command response in this thread if i use mutex lock then it can miss the other commands from resource.

          So in this type of situation what is better way to mange response commands in collection thread.

          i know the threading. but i not know how manage the resources. for that which concept help so it not block or crash.

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

          @Qt-embedded-developer Sorry, but you're not providing enough information and not showing any code - how is anybody supposed to know why it does not work?
          I also don't know why you need mutexes in that other thread? If you use signals/slots to exchange data with main thread there is no need for any mutexes.

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

          Q 1 Reply Last reply
          1
          • jsulmJ jsulm

            @Qt-embedded-developer Sorry, but you're not providing enough information and not showing any code - how is anybody supposed to know why it does not work?
            I also don't know why you need mutexes in that other thread? If you use signals/slots to exchange data with main thread there is no need for any mutexes.

            Q Offline
            Q Offline
            Qt embedded developer
            wrote on last edited by
            #5

            @jsulm Its lots of line code. but i can provide summary:

            there is one system which connected with multiple sensors.

            this system connected to other system. which shows the data.

            so other system is using mutex because it has one part where it has to check sensors connection is there or or not.

            as well as this system has to update collected sensors data on to screen.

            so this connection checking and collection of data happening from separate 2 thread and using one resource.

            jsulmJ 1 Reply Last reply
            0
            • Q Qt embedded developer

              @jsulm Its lots of line code. but i can provide summary:

              there is one system which connected with multiple sensors.

              this system connected to other system. which shows the data.

              so other system is using mutex because it has one part where it has to check sensors connection is there or or not.

              as well as this system has to update collected sensors data on to screen.

              so this connection checking and collection of data happening from separate 2 thread and using one resource.

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

              @Qt-embedded-developer said in How to manage resources in thread without blocking main GUI thread ?:

              so other system is using mutex because it has one part where it has to check sensors connection is there or or not

              What do you mean by "system"? Other application? Other thread? ...?

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

              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