BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 10-31-2007, 08:12 AM   #1 (permalink)
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Post Thanks: 0
Thanked 0 Times in 0 Posts
Lightbulb Getting the EventLock from outside the Application

Please Login to Remove!

I found something interesting today.

My application has a FolderListener registered on the mail store and is alerted when a new mail arrives.
If it is a certain mail i want to update the UI in my application and i have to possibilities to do so:

1. synchronized (UiApplication.getEventLock())
2. invokeLater(new Runnable()...

The first option leads to a Ui accessed without holding the eventlock exception. The second option freezes the device.

As i discovered UiApplication.getEventLock() gives you the eventlock of the calling application, in my case the folderlistener, which can not provide the eventlock.

My solution is to provide a method in the main application:
Code:
public Object getApplicationEventLock() {		
	return getAppEventLock();
}
i now synchronize on this method in my screens and other UI elements:
Code:
synchronized (app.getApplicationEventLock()){
}
I thought this could be helpful for anybody stumbling upon a similar problem.
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 10-31-2007, 09:27 AM   #2 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Oct 2006
Model: 7103
Carrier: Verizon
Posts: 259
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

that is helpful, I find the invokeLater doesn't cause the problem you see, but is not the most efficient or elegant solution. thanks for the tip
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

Johnson Controls Metasys MS-NAE5510-1 MS NAE 5511 5510 Controller Version 7.0
$2499.99
Johnson Controls Metasys MS-NAE5510-1 MS NAE 5511 5510 Controller Version 7.0 pictureMetasys IO-NTU102-0 Rev E
$29.99
Metasys IO-NTU102-0 Rev E pictureJohnson Controls Metasys NU-NCM350-8 NCM-350 Controller Arcnet/Ethernet Combo
$209.99
Johnson Controls Metasys NU-NCM350-8 NCM-350 Controller Arcnet/Ethernet Combo pictureJohnson Controls METASYS MS-IOM4710-0 Series Controller Rev.W S/W Ver.5.0
$113.73
Johnson Controls METASYS MS-IOM4710-0 Series Controller Rev.W S/W Ver.5.0  pictureJohnson Controls METASYS MS-IOM2710-0 2 Universal Inputs and Outputs NIB SEALED
$37.91
Johnson Controls METASYS MS-IOM2710-0 2 Universal Inputs and Outputs NIB SEALED picture






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