How to force the run() function to execute first



  • 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();
    
    

  • Moderators

    This should work:

    QTimer::singleShot(0, []() { clientThread->serverConnect() } );
    

    Or, if serverConnect() is a slot:

    QTimer::singleShot(0, clientThread, &ClientThread::serverConnect());
    


  • I used the started SIGNAL and called serverConnect in SLOT function.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.