PDA

View Full Version : QThread help please



munna
12th September 2006, 11:53
Hi,

I have a console application in which I have reimplemented QCoreApplication. Also, I am creating n(sent as an argument) threads in the following manner




Thread *t = new Thread(ipAdd, serialNo, noOfSecs, perSec);
++threadCount;
connect(t, SIGNAL(finished()), this, SLOT(threadFinished()));
connect(t, SIGNAL(finished()), t, SLOT(deleteLater()));
t->start();



Here is the slot threadFinished()




void Application::threadFinished()
{
--threadCount;
if(threadCount == 0){
exit();
}
}



The above slot is never called itself and therefore I am not able to exit from the application.

Can someone please help me with this ?
Thanks a lot.

jpn
12th September 2006, 12:01
How is Thread implemented? Does it enter to an event loop? If it enters to an event loop, is QThread::quit() ever called? If it doesn't enter to an event loop, does it ever reach the end of QThread::run()?

munna
12th September 2006, 12:07
Oh, I think I got your point and realized my mistake.

Thanks a lot for pointing it out.
Thanks.