If you are using Internet Explorer, please remove blackberry.com from your compatibility view settings.

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
Mudassir
Posts: 209
Registered: ‎11-08-2008
My Device: Not Specified

Uncought exception found in blackberry

[ Edited ]

Hi all,

     I am implementing share trading application using Blackberry.When I place Order for "LIMIT TYPE" the following exception found.."Uncought exception blocking Operation not permitted on event dispatched thread".

What is the Problem?

 

We are doing network operation by invoke letter.Will it not solve the problem?

 

Thanks in Advance :smileyhappy: 

Message Edited by Mudassir on 01-09-2009 04:47 AM
Thanks and Regards
Please use plain text.
Developer
simon_hain
Posts: 15,893
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: Uncought exception found in blackberry

the message means that you process something on the main event thread.
time consuming actions should be processed in an own thread, especially networking.
----------------------------------------------------------
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
Please use plain text.
Developer
Mudassir
Posts: 209
Registered: ‎11-08-2008
My Device: Not Specified

Re: Uncought exception found in blackberry

Thanks for reply.

 

Actually, i am implementing the code given below:-

 

UiApplication.getUiApplication().invokeLater(new Runnable()
            {
                    public void run()
                    {

 

// sending message to the socket Server

                        socketHandler.getInstance().placeOrder(message);


                        UiApplication.getUiApplication().popScreen(UiApplication.getUiApplication().getActiveScreen()); 
                        UiApplication.getUiApplication().pushScreen(ListForm.getInstance());
                    }  
            }); 

 

I could place the line("socketHandler.getInstance().placeOrder(message);") out of invokeLater().

But i think that it will not solve the problem because the upper given block is called on buttonClick navigation.

So how can i overcome the error

 

Thanks and Regards
Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: Uncought exception found in blackberry

invokeLater() does NOT start a new Thread, it jest creates a unit of work that the dispatcher can run later.  I believe it will run under control of the main Thread for the Application that invokes it, in this case, the UiApplication main Thread, so you are blocking.

 

Start a new Thread for network processing.  The samples and JDE include code that will show you how to do that.

Please use plain text.
Developer
marchywka
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: Uncought exception found in blackberry

I guess there are two issues:

1) Don't hold a lock while calling code that is not predictable- any IO qualifies. The UI thread effectively holds a lock.

2) Don't lock out user with various modes when you can keep the app responsive and queue up request in the background. Between the time a request is made and a response obtained a lot can happen- including mashing

the keyboard and swearing trying to get the app to respond. I've even gone to global notifications

in some cases- user makes request, then goes check email and can get confirmation popup while in other app.

If you really want, I guess you could grey-out some menu options but a modal lock out rarely makes sense.

 

 

 

Please use plain text.
Developer
Mudassir
Posts: 209
Registered: ‎11-08-2008
My Device: Not Specified

Re: Uncought exception found in blackberry

Hi,

Thanks for rply, but please tell me that my application already have two threads running. And creating a third thread will cause any proble in speed and memory consumption. And there is only way to get rid of that exception?

 

Thanks.

Thanks and Regards
Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: Uncought exception found in blackberry

I wouldn't worry unduly about three Threads.  You are allowed up to 16 threads, but given other system requirements, I would recommend not using more than 12.  If your application design or system architecture needs the Threads, then use them.  But do make sure these are coded in a way that minimizes overhead, in terms of processor and memory, especially watching out for memory leaks.  Three well written Threads will have less system impact than one badly designed/coded one.

 

You probably don't need to have the network Thread running if you are not doing frequent calls - just start and stop it when you need it. 

Please use plain text.
Developer
simon_hain
Posts: 15,893
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: Uncought exception found in blackberry

a thread does not cost you much - and you can have a lot more then two threads.
after the networking is done the thread ends.
----------------------------------------------------------
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
Please use plain text.