creekorful creekorful - 1 year ago 94
C++ Question

How to unpause thread in Qt

I wanna know if there is a way to unpause a sleeping thread in Qt

I pause the thread using QThread::msleep(ms) function

And i want to unpause the thread before time runs out

Is there any way to do it ?

Thank in advance, Creekorful

Answer Source
QMutex mut;

void InterruptMethod() {

void SleepMethod() {
  const int kTimeout = 5000;
  bool over_event_come = mut.tryLock(kTimeout); // here was sleep
  if (over_event_come) {
    // unlock from another place
  } else {
    // exit by timeout
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download