Thread: delaying for milli, microseconds

  1. #1
    Registered User wazilian's Avatar
    Join Date
    Oct 2001

    Question delaying for milli, microseconds

    anybody know how to delay a C program for a given number of milliseconds or microseconds? any help would be appreciated. thanx in advance.
    King of Wazil

  2. #2
    Banned Troll_King's Avatar
    Join Date
    Oct 2001
    It's compiler dependant. Type #include<time.h>, put your cursor on the word and hit F1 key, or else Ctrl-F1. If you have Visual Studio.NET than you can use the dynamic help.

  3. #3
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    from <windows.h> use Sleep(x) where x is number of millisecs you want to delay for.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :-

  4. #4
    Registered User
    Join Date
    Sep 2001
    And you will never get beyond milliseconds with a windows OS. Microsecond sleep control is kind of pointless, anyway, because of multitasking, you're only guaranteed to wait AT LEAST a certain length of time.

    So, sleep(10) will make your thread sleep for AT LEAST 10 milliseconds, but it could sleep for 10, 20, 50, a million, depending on what else is running.

    The only way to avoid this is to give the thread realtime priority, but that is VERY inadvisable to use frequently, as it will steal all the processor time, not even giving anything to the routine OS tasks it always does.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Determine process time in microseconds
    By kenkoh in forum C Programming
    Replies: 9
    Last Post: 02-18-2008, 02:16 PM
  2. Replies: 2
    Last Post: 01-22-2008, 04:22 PM
  3. Execution Time in Microseconds?
    By thetinman in forum C++ Programming
    Replies: 11
    Last Post: 06-02-2007, 01:32 PM
  4. microseconds control?
    By jcly in forum C Programming
    Replies: 1
    Last Post: 11-28-2003, 07:38 AM