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
Posts: 553
Registered: ‎10-31-2009
My Device: Torch 9800, Bold 9700
My Carrier: Movistar, Telenor

Re: Use Persistent Storage or other methods to Synchronize

 

 

could you elaborate that a bit?

If everything seems to be under control, you're just not driving fast enough
-Mario Andretti-
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Use Persistent Storage or other methods to Synchronize

Yes.  The background Thread will fire a Global Event, which will start a method in your UiApplication, that will do the callback.

Developer
Posts: 562
Registered: ‎09-30-2009
My Device: Not Specified

Re: Use Persistent Storage or other methods to Synchronize

[ Edited ]

Read the API documents, especially for RuntimeStore.waitFor. Once understood, then you can think about how to coordinate two threads in two different processes by using signalling with the RuntimeStore, and it should be fairly apparent. Using blocking and wait/notify properly with threads is much more advantageous to using threads and polling.

 

This is in some way complementary to what peter_strange is proposing -- using the PersistentStore doesn'treally get you anything than data that persists over a reboot.

Developer
Posts: 553
Registered: ‎10-31-2009
My Device: Torch 9800, Bold 9700
My Carrier: Movistar, Telenor

Re: Use Persistent Storage or other methods to Synchronize

The choice of Persistent Storage was just out of conveinience from my part since I used it for other purposes. I will check out Runtime and waitfor

If everything seems to be under control, you're just not driving fast enough
-Mario Andretti-
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Use Persistent Storage or other methods to Synchronize

In this sort of circumstrance where it is important that messages in the message q are sent, even if they are sent after a reboot,, I would retain them in PersistentStore. 

Developer
Posts: 553
Registered: ‎10-31-2009
My Device: Torch 9800, Bold 9700
My Carrier: Movistar, Telenor

Re: Use Persistent Storage or other methods to Synchronize

[ Edited ]

Its not neccessary for these replies to be retained over a reboot. The waitfor function seems to favor Runtime storage.

 

The only drawback is that I cannot control how long to wait. it iseems to be locked to MAX_WAIT_MILLIS (or 2 minutes)

If everything seems to be under control, you're just not driving fast enough
-Mario Andretti-
Highlighted
Developer
Posts: 553
Registered: ‎10-31-2009
My Device: Torch 9800, Bold 9700
My Carrier: Movistar, Telenor

Re: Use Persistent Storage or other methods to Synchronize

Could not be simpler:

RuntimeStore containing just a String to return

 

Sending command:

 

       String returnValue="";
       Redirector_settings settings = new Redirector_settings();
       RuntimeStore Rstore = RuntimeStore.getRuntimeStore();
       Rstore.remove(settings.Runtime);
       CreateAlert(settings.Debug,"Sending command to Redirector:  " + parm1);
      ApplicationManager.getApplicationManager().postGlobalEvent(settings.GE_Orders,settings.ServerCommand,0,parm1,"");
      returnValue = (String) Rstore.waitFor(settings.Runtime);
      CreateAlert(settings.Debug,"Got answer from Redirector:  " + returnValue);
      settings=null;
      return returnValue;
     } 

 

And Redirector just sets the store after handling the request

 

Rstore.put(settings.Runtime,ReturnValue)

If everything seems to be under control, you're just not driving fast enough
-Mario Andretti-