BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 01-20-2010, 11:05 PM   #1 (permalink)
New Member
 
Join Date: Oct 2009
Model: 8820
PIN: N/A
Carrier: abc
Posts: 8
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Blocking operation-How to fix?

Please Login to Remove!

When i debug my program on device. I see the debug window informed that "blocking operation not permitted on event dispatch thread". And this exception thrown from this line in my code "streamConnection = (StreamConnection)Connector.open(getEndPoint(endPo int, WIFI));".

And this is getEndPoint code :

Code:
private static String getEndPoint(String endPoint, int connectionType){
                String s;
                switch (connectionType) {
                        case WIFI:
                                s = endPoint + ";interface=wifi";
                                break;
                        default:
                                s = endPoint;// + ";deviceside = true";
                                break;
                }
                
                return s;
        }
Offline  
Old 01-21-2010, 08:36 AM   #2 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

It is the Connector.open() that is causing the issue. THis needs to be done in a worker thread.

If you perform a blocking operation (like this) in the event thread, your event queue will overflow, causing the OS to dump your program as "non-responsive".
Offline  




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