Timers to take msg

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rajbala
    New Member
    • Oct 2006
    • 58

    #1

    Timers to take msg

    Hi all,

    I newbe for using a timers.
    my requirement is when i enter a message name like " start " ,If it doesn't start in the particular time e.g in 20 seconds then it show the a dilaog box or any printf like start function is not start.

    please help me i need your help..........

    really any type suggestion is appricited..

    thank you..

    -Raju
  • Transmit
    New Member
    • Dec 2006
    • 11

    #2
    this is a function for a timer:

    Code:
    void sleep(unsigned int mseconds){
    	 clock_t goal = mseconds + clock();
    	 while (goal > clock());
    }
    usage:

    Code:
    printf("The program is now waiting 5 seconds and will start the program after");
    sleep(5000)
    startprogram();
    
    if (variable == 1){
      printf("It started");
    }else{
      printf("It hasn't started");
    }
    
    // get something in the function startprogram() to set a variable to 1
    // 5000 is the milliseconds the program waits so 5000 = 5 seconds.
    // when sleep is running you can't do anything else!

    I don't know if that's what you actually meant, maybe you should try it out.

    Comment

    Working...