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
Contributor
Posts: 12
Registered: ‎10-29-2010
My Device: Not Specified

Re: Pushing a Popup Screen

thanks for the code snippet.......but i dont think you understood me.......i've done exactly the same thing.....but my ques is.....i need to change the value of the variable in this thread i.e. WorkerRunnable as you've put it..... and then do my logic based on the value of the changed variable.....i.e. something like this......how do i do this.......

 

public class WorkerRunnable implements Runnable {
private boolean var;

public WorkerRunnable(){

}

public void run() {
// do some work
// modify the var
this.var = false;
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run() {
// update UI here, can call screen method
setMyScreenData(-1);
}
});
}

}


// invoking the above thread in my code

WorkerRunnable thr = new WorkerRunnable();
thr.start();
// wait for the WrokerRunnable thread to modify the variable and
// return back
if(thr.var)
//do something

 

New Developer
Posts: 45
Registered: ‎05-25-2010
My Device: 8300
My Carrier: developer

Re: Pushing a Popup Screen

If WorkerRunnable is inner class:

 

public class WorkerRunnable implements Runnable {
        private boolean var;

        public void run() {
            // do some work
            // modify the var
            this.var = false;            
            UiApplication.getUiApplication().invokeLater(new Runnable() {
                public void run() {
			doSomething(var);
                }
            });
        }
        
    }

 In main class:

 

// in main class 
void startRunnnable(){
	WorkerRunnable thr = new WorkerRunnable();
	thr.start();
	// wait for the WrokerRunnable thread to modify the variable and 
	// return back
}
void doSomething(boolean var){
	// process changes here
}

 

 

If WorkerRunnable is top-level class, you can pass caller class instance into WorkerRunnable constructor.

 

Highlighted
Contributor
Posts: 12
Registered: ‎10-29-2010
My Device: Not Specified

Re: Pushing a Popup Screen

yeah......this should work.........didnt use the inner class approach..........thanks a lot Smiley Happy