2 Replies Latest reply on Apr 12, 2007 11:54 PM by 807596

    Pause a timer

      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

          2-Subclass Timer to fill your need.

          • 2. Re: Pause a timer
            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.
            int count=0;
            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