PDA

View Full Version : How to force the run() function to execute first



nitks.abhinav
6th November 2017, 18:02
Hi ,

I have below code where I see that the run function of the clientThread runs after the serverConnect() function. How can I force the run() function to execute first before serverConnect.

Thank you,

`
clientThread->start();

/* Connect to the notification server. */
clientThread->serverConnect();

^NyAw^
6th November 2017, 18:15
Hi,

You can use the SIGNAL "started" to a SLOT and in this SLOT call the other function.



connect(clientThread,SIGNAL(started()),this,SLOT(m yThreadStarted()));
clientThread->start();

void myClass::myThreadStarted()
{
clientThread->serverConnect();
}

nitks.abhinav
6th November 2017, 19:25
It worked, Thanks for help!