/***************************************************************************************** * Function Description: Millisecond non-blocking delay function
* Parameter: Delay millisecond number
* Other instructions: tested, available, but with high CPU usage
*****************************************************************************************/
void Vdpumngui::msecsleep (int msec)
{
Qtime dietime = Qtime::currenttime (). Addmsecs (msec);
while (Qtime::currenttime () <dietime)
Qcoreapplication::p rocessevents (qeventloop::allevents, 100);
}
/*****************************************************************************************
* Function Description: Millisecond-level non-blocking delay function
* Parameter: Delay millisecond number
* Other instructions: not tested
*****************************************************************************************/
void Vdpumngui::msecsleep (int msec)
{
Qmutex Mutex;
Qwaitcondition sleep;
Mutex.lock ();
Sleep.wait (&mutex, 1000);
Mutex.unlock ();
}
/*****************************************************************************************
* Function Description: Millisecond blocking Delay function: API function sleep (int msec)
* Parameter: Delay millisecond number
* Other instructions: tested, available, note the first letter S to capitalize, basically do not occupy the CPU
*****************************************************************************************/
/*****************************************************************************************
* Function Description: Millisecond blocking delay function
* Parameter: Delay millisecond number
* Other instructions: not tested
*****************************************************************************************/
void Vdpumngui::msecsleep (int msec)
{
Qtime N=qtime::currenttime ();
Qtime now;
do{
Now=qtime::currenttime ();
}while (N.msecsto (now) <=msec);
}