This discussion is archived
2 Replies Latest reply: Apr 12, 2007 4:54 PM by 807596 RSS

Pause a timer

807596 Newbie
Currently Being Moderated
I have a periodic task and I need to pause it for a undefined time.
but when the periodic task is restarted it should remember the time that spent since the last periodic event till the begining of the undefined time,this way the first periodic event should be shorter than normal.
can it be implemented with a Timer object?
atherwise how can i do?
  • 1. Re: Pause a timer
    807596 Newbie
    Currently Being Moderated
    HI,

    1-Nope
    2-Subclass Timer to fill your need.

    Jack
  • 2. Re: Pause a timer
    807596 Newbie
    Currently Being Moderated
    What you can do is use thread.sleep to sleep for whatever amount of time you want it to wait for. Then have that placed inside of a while loop and have a counter to determine how many times it goes through till your condition it met. So something like this.
    try{
    int count=0;
    while(!condition)
    {Thread.sleep(50);
    count++;}
    catch(InterruptedException e){}
    double time=(count*50)/1000;

    That is what I would do. Of course when your done time will be in seconds so you can adjust for your needs