Results 1 to 7 of 7

Thread: Problem with Sleep() - pls help.

  1. #1
    Senior Member
    Join Date
    Sep 2001
    Posts
    535

    Problem with Sleep() - pls help.

    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
    A laptop, internet connection and beer.

  2. #2
    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:
    Code:
    sleep(1000);
    will wait for 1 second.

    hope this helps

  3. #3
    Senior Member
    Join Date
    Sep 2001
    Posts
    535
    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 ?
    A laptop, internet connection and beer.

  4. #4
    i don't think it will, but to keep it compatible with other compilers, you should add it

  5. #5
    Senior Member
    Join Date
    Sep 2001
    Posts
    535
    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.
    A laptop, internet connection and beer.

  6. #6
    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

  7. #7
    Senior Member
    Join Date
    Sep 2001
    Posts
    535
    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
    A laptop, internet connection and beer.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •