BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 10-04-2005, 03:32 PM   #1 (permalink)
New Member
 
Join Date: Sep 2005
Model: 7250
Posts: 10
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default blocking operations in event dispatch thread

Please Login to Remove!

I'm trying to write an app which creates a socket connection to a remote server and writes a command string to it. It worked fine in the simulator, but when I copied it to the handheld, I got an error about blocking operations not being permitted in the event dispatch thread. Next, I tried creating a Runnable object and using InvokeLater, like this:

Runnable sendQuery = new Runnable() {
public void run() {
try {
StreamConnection conn = null;
conn = (StreamConnection)Connector.open(URL);
OutputStreamWriter _out = new OutputStreamWriter(conn.openOutputStream());
String data = "query " + myContextField.getText() + "\n";
int length = data.length();
_out.write(data,0,length);
_out.close();
conn.close();
}
catch (Exception e) {
Dialog.inform("Error: " + e);
}
}
};
invokeLater(sendQuery);

But I get the same thing. What do I need to do?

Thanks!
Offline  
Old 10-05-2005, 10:49 AM   #2 (permalink)
New Member
 
Join Date: Aug 2005
Model: 7290
Posts: 5
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

You need to create a new Thread to run this in, so that it does not run in the event dispatch thread.

blackberry.com/developers has more info on how to do it, as well as how to access UI fields from the background thread
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

2 PCS CAT24C256LI DIP-8 CAT24C256 24256E 256 kb I2C CMOS Serial EEPROM
$3.99
2 PCS CAT24C256LI DIP-8 CAT24C256 24256E 256 kb I2C CMOS Serial EEPROM picture5 PCS AT24C256-10PU-2.7 DIP-8 AT24C256 24C256 2-Wire Serial EEPROM
$3.49
5 PCS AT24C256-10PU-2.7 DIP-8 AT24C256 24C256 2-Wire Serial EEPROM picture5 PCS AT25080AN-10SU-2.7 SOP-8 AT25080 25080AN SMD-8 EEPROM
$6.59
5 PCS AT25080AN-10SU-2.7 SOP-8 AT25080 25080AN SMD-8 EEPROM picture2 PCS X5043P DIP-8 X5043 CPU Supervisor with 4K SPI EEPROM
$3.99
2 PCS X5043P DIP-8 X5043 CPU Supervisor with 4K SPI EEPROM picture50 PCS AT24C256C-SSHL-T SOP-8 AT24C256 2ECL SMD Serial EEPROM
$14.99
50 PCS AT24C256C-SSHL-T SOP-8 AT24C256 2ECL SMD Serial EEPROM picture






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