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  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





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