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: 1,474
Registered: ‎04-14-2009
My Device: Not Specified

Re: Retrieve value from Dialog.ask

BTW, a solution mentioned by peter_strange in the above referenced thread will also work, provided the invoking thread is guaranteed not to hold any locks:

 

 

int choice;
synchronized (Application.getEventLock()) {
  choice = Dialog.ask(...);
}

 

 

What this will do, is wait until the current event thread isn't processing a message, acquire the event lock, start the event loop (thus moving it from the original event thread into this thread, thus temporarily turning this thread into the event thread), stop the event loop once the dialog has been dismissed, assign the "choice" variable, release the lock (thus resuming the event loop in the original event thread).

 

This is fine as long as the thread is guaranteed not to hold any other locks before attempting to acquire the applicaiton's event lock. Otherwise a dead-lock is possible.

Please use plain text.