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

New Contributor
Posts: 2
Registered: ‎12-06-2011
My Device: 9800
My Carrier: tim
Accepted Solution

How to update view without freezing?

Hi all,

I'm trying to load more elements in a list like the Twitter application does




When I want to load more elements, I perform the following actions:


  • I show Loader
  • I do Networking activity
  • I update the view

The problem is that during the "update view" step the application UI is freezing (for 2, 3 seconds).

Since I'm not in the main thead I update the viwe in the following way:


UiApplication.getUiApplication().invokeLater(new Runnable() {
            public void run() {
                synchronized (UiApplication.getEventLock()) {
                    while (MyList.hasMoreElements()) {

 Is there a way to update the view without freezing the interface??

Thank you all.

Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: How to update view without freezing?

welcome to the support forum.

invokelater is enough, you don't have to synchronize on the event lock.

i don't know what ScrollableList is, but if you would use a ListField, for example, you could add all entries at once.
Even in other cases, like a normal manager, addAll might be a lot better performance-wise.
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to update view without freezing?

[ Edited ]

Agree with Simon.


You should try to do the smallest amount of processing in the invokeLater that you can.  So no processing of data, you should create the array of items you want to add and then only do the add in the invokeLater.  in addition, you might be able to use one of the new array addAll method which is significantly faster because it will only 'layout' your manager once.


Hopefully that will be enough. 

Posts: 285
Registered: ‎08-06-2010
My Device: Z10

Re: How to update view without freezing?

I'd recommend limiting your use of synchronized only to times where it's absolutely necessary (e.g. database transactions). 


InvokeLater is your best choice. However, be aware that if you call too many invokeLaters (especially if your calls are take long to complete), you will overflow the event queue and crash your application. You have to manage it carefully.

Follow me on twitter @RileyGB - https://twitter.com/RileyGB
View my BB10 OpenSource projects - https://github.com/RileyGB/BlackBerry10-Samples
New Contributor
Posts: 2
Registered: ‎12-06-2011
My Device: 9800
My Carrier: tim

Re: How to update view without freezing?

Avoiding  to synchronize on the event lock, and using the addAll method of my ScrollableList (that is a Vertical Field Manager) accelereted significantly the view update.


Many thanks to all of you.