Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
misty83
Posts: 745
Registered: ‎01-04-2009
My Device: 8300, 8800, 8700f, 9000
Accepted Solution

how to change schedule timer in timer?

hi, i've got such a problem:

 

i've got timer which does every minute. but i want to change schedule time when proper conditions happens:

 

Timer timer = new Timer();

 

timer.scheduleAtFixedRate(new TimerTask(){

 

public void run(){

 

if(something happens){

  myTime = 2*myTime;

}

 

}

 

 

}, 0, myTime);

 

 

how can i make that the schedule time change to '2*myTime'?

 

regards

Please use plain text.
Developer
simon_hain
Posts: 15,806
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: how to change schedule timer in timer?

cancel old task. schedule new task.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
misty83
Posts: 745
Registered: ‎01-04-2009
My Device: 8300, 8800, 8700f, 9000

Re: how to change schedule timer in timer?

can't i change this schedule time somehow?

Please use plain text.
Developer
simon_hain
Posts: 15,806
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: how to change schedule timer in timer?

no. what would be the difference, anyhow?

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
misty83
Posts: 745
Registered: ‎01-04-2009
My Device: 8300, 8800, 8700f, 9000

Re: how to change schedule timer in timer?

cause these conditions to change schedule time would be a lot..i must change schedule time every 'some time' and 'some conditions'. so it would be more than one to change it.. so what, every time the 'time' is changed i must cancel the timer and create a new one? code wont be nice..

Please use plain text.
Developer
misty83
Posts: 745
Registered: ‎01-04-2009
My Device: 8300, 8800, 8700f, 9000

Re: how to change schedule timer in timer?

ok, i've done it as You've suggested and it works!

 

 thx and regards

Please use plain text.
Developer
simon_hain
Posts: 15,806
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: how to change schedule timer in timer?

just as an annotation: timer is the container class. you don't have to cancel the timer, only the timertask.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.