BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 11-01-2010, 04:01 PM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Jun 2010
Model: 8530
PIN: N/A
Carrier: Sprint
Posts: 48
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Changing the timeinterval in invokeLater() method

Please Login to Remove!

Setting true for repeat parameter, the invokeLater() method continually re-adds the runnable object to the event queue, pausing the time (in my case, 10 sec) between each insertion.

Code:
public static int timeInterval=10000;

UiApplication.getUiApplication().invokeLater(new Runnable() {
			public void run() {
				//code to print the list
			}
		}, timeInterval, true);
Now I need to change the timeInterval dynamically while running the application. Changes in global variable 'timeInterval' doesnot effect its execution because time is already set before executing the thread.

So, I think I need to kill the thread and restart again with new timeInterval. Is this the way to solve it ? What will be the good solution for this?

Romah

Last edited by romah : 11-01-2010 at 04:06 PM.
Offline  
Old 11-01-2010, 05:11 PM   #2 (permalink)
Knows Where the Search Button Is
 
Join Date: Jun 2010
Model: 8530
PIN: N/A
Carrier: Sprint
Posts: 48
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I tried using cancelInvokeLater() . It displays the list in old timeInterval.

Code:
public static int timeInterval=10000;

private void callTimer()
{
int runnableID = UiApplication.getUiApplication().invokeLater(new Runnable() {
			public void run() {

				//code to print the list

			}
		}, timeInterval, true);
}

timeInterval=30000;

UiApplication.getUiApplication().cancelInvokeLater(runnableID);

callTimer();
Any idea please ?

Last edited by romah : 11-01-2010 at 05:12 PM.
Offline  




Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.