[SOLVED]Best practices for capturing application state change on multiple threads
-
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
-
Hi,
Connecting
applicationStateChanged(Qt::ApplicationState)
to both sounds reasonable.I don't think you need to do something more complicated.