Hi.
I have two threads in my application.i am using them in several functions.But in one function i do calculation-1 then call thread-1.I need to wait till thread-1 get finished then i need to do calculation-2 and start thread -2.
But i dont know how to stop the process after calling the thread-1.
example:
void onstartbutton()
{
....................
.............
............... i am sending data to socket
thread1->start();
.............
............
............i am sending data to same socket
thread2->start()
}
after starting the thread one i need to wait till it get finished.I have used
while(!thread->isrunning());
but my gui is getting blocked.
I thought to use thread finished signal like this
connect(thread1,SIGNAL(finished()),this,SLOT(onfin ished1()));
but no use.
and while debugging i came to know that i the socket operations after the thread-1 not working .
can any one please tell me how to fix it.........
Thanks
Added after 34 minutes:
well here is my code for reference.
mainform.cpp
void MainForm:n_pstartBtn_clicked()
{
wbufstr = "PP0";
bawbuf = wbufstr.toUtf8();
bytsentv = pedsock->write(bawbuf,bawbuf.length());
pedsock->waitForBytesWritten(2000);
if(bytsentv != bawbuf.length())
QMessageBox::warning(this,"Antenna Control Unit","Failed to Send PP command",0,1);
memset(mreadbuf,'\0',40);
panthread->start()
wbufstr = "TP0";
bawbuf = wbufstr.toUtf8();
bytsentv = pedsock->write(bawbuf,bawbuf.length());
pedsock->waitForBytesWritten(2000);
if(bytsentv != bawbuf.length())
QMessageBox::warning(this,"Antenna Control Unit","Failed to Send TP command",0,1);
memset(mreadbuf,'\0',40);
tiltthread->start();
}
panthread.cpp
void panthread::run()
{
this->PanStop = false;
for(; ; )
{
if(this->PanStop)
break;
emit PanReadAngle();
this->msleep(100);
}
}
tiltthread.cpp
void tiltthread::run()
{
this->tiltStop = false;
for(; ; )
{
if(this->tiltStop)
break;
emit tiltReadAngle();
this->msleep(100);
}
}
here panreadangle (), and tiltreadangle() are signals connected to panpos in my main form.
i cand send both commands to my pedestal which is interfaced through ethernet.so i need to wait untiol panthread is finished.then i need to send other commands to pedestal.
how can i stop the tiltthread till panthread get finished.
Bookmarks