PDA

Click to See Complete Forum and Search --> : Problem with Sleep() - pls help.


intruder
October 9th, 2004, 01:58 PM
Hi All,

I am using extensive Sleep() function in my application coz i want it to halt at certain point of time. But some people told me that Sleep() is machine dependant as my application doesn't show consistant behavior from machine to machine.

Hence i am trying to use SetTimer() OnTimer() functions to achieve the Sleep() functionality but it ain't happening coz whenever i try to do SetTimer() it executes the OnTimer function independantly as a seperate process and control doesn't stop there.

pls help me how can i achieve the Sleep() functionality without actually using
Sleep() function. Is there any other way we can do the same ?

Thanks in advance.


In

lepricaun
October 9th, 2004, 07:39 PM
i can't believe it is machine dependant, i think it is OS dependant. if you want it to use for windows, then include windowsx.h. this will allow you to use the sleep function in miliseconds.

for instance:

sleep(1000);
will wait for 1 second.

hope this helps ;)

intruder
October 11th, 2004, 12:43 PM
hi lepricaun,
Sleep() func. works without including the header file also, i mean it does not give any compilation errors. So will the performance of Sleep() change if we don't include the windowsx.h header file ?

lepricaun
October 11th, 2004, 06:02 PM
i don't think it will, but to keep it compatible with other compilers, you should add it ;)

intruder
October 15th, 2004, 10:54 AM
It is working without the header file also and it did not made any difference even if i included it. I am using VC++ editor.

lepricaun
October 15th, 2004, 12:45 PM
well, it does make a difference, it is possible that your compiler includes that headerfile by default, but another one might not, thats why it is best to include it anyway.

hope this makes sence to you :D

intruder
October 15th, 2004, 06:30 PM
ok i agree with u but how to simulate this Sleep function without using Sleep actually ?
i have tried many things but it seems nothing is working..

just let me know if anybody gets any idea..

Thanks :)