tags:

views:

43

answers:

1

if the maximum wait time is 10 ms can i use qwaitcondition in Qt's main thread?

+4  A: 

Nothing stops you from using QWaitCondition in the main thread. If you are setting the wait time to 10ms, and it passes without unlocking you will probably not get the desired effects you want. The default is to wait indefinitely.

However, using a wait condition in the main thread will cause the GUI to become unresponsive while it waits. This is almost always undesired.

Adam W
ive been using it currently with a sleep function of 1ms and a a retyrcount maximum and its been very responsive, no lag at all and I have a safe handling implementation in case of quiting after 10 ms. I just think maybe a wait would be safer than calling sleep in the gui main thread not for the time it would be sleeping that is not an issue but the risk of having the gui being frozen for a mysterious reason
yan bellavance
@yan bellavance: There will be no appreciable difference between wait and sleep, as the wait function will suspend execution at that point until its conditions are fulfilled, just like sleep does.
Caleb Huitt - cjhuitt