PDA

View Full Version : Window blacked out (not responding) even while updating status constantly



chytu
7th January 2012, 13:11
Hi,

I am updating the status of a worker thread in GUI using the following code:


while(!grabber->bGrabberFinished)
{
ui->statusBar->showMessage(grabber->status);
ui->label->setText(grabber->status);
ui->label->update();

ui->progressBar->setValue(grabber->progress);
ui->progressBar->update();

boost::this_thread::sleep (boost::posix_time::milliseconds(40));
}


Here, my worker thread updates the grabber object's progress and status (so the grabber object is shared between the GUI thread and the worker thread).

Everything works fine (my GUI is updated at regular intervals), but during this process, Windows blacks out my screen as "not responding" even though the label is updated every 40 milliseconds...

What am I doing wrong?

Thanks,
Chytu.

stampede
7th January 2012, 14:18
Read this, if you haven't already : http://gutenberg.trolltech.kunder.linpro.no/qq/qq27-responsive-guis.html

chytu
7th January 2012, 16:42
Thank you very much for the link. Din't know about the timer.

Using timer timeout() to convert the busy wait (or the sleep command) into a signal-slot thingy solved the problem...