I would like to write a function that pauses the computer for a specified amount of time. I use Visual C++ 6.0. Any ideas?
Printable View
I would like to write a function that pauses the computer for a specified amount of time. I use Visual C++ 6.0. Any ideas?
Hi,
Do you want to pause the entire OS, or just your program. If you just want to pause your program, then you could use a function like this:
void MilliSleep (LONG lSleepTime) // Function to make the computer wait X milliseconds
{
LONG lTimeNow, lGoal;
lTimeNow = lGoal = time(NULL); // Get the number of milliseconds after Jan. 1, 1970
lGoal += lSleepTime;
while (lTimeNow<lGoal)
lTimeNow = time(NULL);
}
Hope this helps.
Daniel.
you would need to access the system clock, but I don't know the code to do that.
#include<time.h>
bool time_out_spec(int milli_seconde)
{
int x=0;
int y=0;
y=clock();
int msec=milli_seconde;
debut://french word meaning start
x=clock();
if ((x-y)>=msec)
{
return 1;
}
else goto debut;
}
this is how I do that,
void main()
{
time_out(500);
cout<<"half seconds have past"<<endl;
}
I think that it's good, I never have compiler
error, no warning at level 4 (VC++ 6.0).