Click to See Complete Forum and Search --> : How do I make a wait() which doesn't use all processor time while waiting?


Berntsen
April 21st, 1999, 06:34 AM
I need a wait(float seconds) function.
This is one alternative:

#include <time.h>

void wait(float seconds)
{
long waitingTime = seconds * CLOCKS_PER_SEC;
clock_t goal = waitingTime + clock();
while (goal > clock());
}



But this function consumes all processor time. I need a function that does the same thing, but does not consume all processor time. Can somebody help me?

Thank you.

Martin vd Berg
April 21st, 1999, 07:04 AM
Use Sleep() or SleepEx() API calls.

Martin van den Berg
High Tech Automation
The Netherlands
Martin.van.den.Berg@hta.nl

Philip McGahan
April 27th, 1999, 09:42 PM
Email me at PMCGAHAN@UCSWORKS.COM and I will send you a routine.

Phil McGahan
(303) 252-8889
12100 Elizabeth St.
Thornton, Colorado 80241