01-09-2009 01:09 AM - edited 01-09-2009 04:47 AM
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
01-09-2009 03:38 AM
01-12-2009 06:31 AM
Thanks for reply.
Actually, i am implementing the code given below:-
public void run()
// sending message to the socket Server
I could place the line("socketHandler.getInstance().placeOrder(messa
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
01-12-2009 07:15 AM
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.
01-12-2009 08:30 AM
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.
01-12-2009 10:26 AM
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?
01-12-2009 10:48 AM
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.
01-12-2009 10:49 AM