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. [SOLVED]Best practices for capturing application state change on multiple threads

[SOLVED]Best practices for capturing application state change on multiple threads

Scheduled Pinned Locked Moved General and Desktop
ios
2 Posts 2 Posters 940 Views 2 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.
  • D Offline
    D Offline
    DRoscoe
    wrote on last edited by DRoscoe
    #1

    I have a single-threaded iOS app. The main program code is contained in a class instantiated by the main application thread and runs on that thread. I am capturing application state changes in the main class:

    void TapDisplaySingleton::run()
    {
      [...]
    
      // capture application state changes (tablet support for sleep mode)
      QObject::connect(this->parent(), SIGNAL(applicationStateChanged(Qt::ApplicationState)),
                       this, SLOT(handleApplicationStateChange(Qt::ApplicationState)));
     [...]
    }
    

    I have a socket communications class that also runs on the main thread and I feel like it is causing intermittent delays in responding to user input. My intention is to move the socket connection to its own thread.

    My question is, what is the best way for BOTH the main class and the thread running my socket code to receive the application state change? The main code will shut down graphics updates, etc and the socket thread will close out communications

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

      Hi,

      Connecting applicationStateChanged(Qt::ApplicationState) to both sounds reasonable.

      I don't think you need to do something more complicated.

      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
      1

      • Login

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