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
robert30
Posts: 191
Registered: ‎04-02-2013
My Device: BlackBerry Bold 9900
My Carrier: developer
Accepted Solution

Problem in running networking application

Hello

 

I want to ask what is the better approach of doing network related application.Do i have to create the Custom thread for this or implements the Runnable Interface.

 

And how to start them by simply calling the .start() in case of thread or .run() in case of interface?

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

Re: Problem in running networking application

threads are always started by start().
you can use new Thread(){}.start() and overwrite the run function of thread for the shortest implementation.
----------------------------------------------------------
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
robert30
Posts: 191
Registered: ‎04-02-2013
My Device: BlackBerry Bold 9900
My Carrier: developer

Re: Problem in running networking application

Thanks Sir for the reply

 

Sir i have to perform multiple networking task in the same buttom click.

Like if i click a button 3 webservices are called, then i have to start the 1 thread in that i will start the other two??

Please use plain text.
Developer
robert30
Posts: 191
Registered: ‎04-02-2013
My Device: BlackBerry Bold 9900
My Carrier: developer

Re: Problem in running networking application

And 1 more problem.

When i click on a Bitmapfield. A popup screen has to be displayed.

 

SO when i click on Bitmapfield, i simply push the popup screen but it doesnot displayed.Then i add the thread and the i got the exception saying pushscreen without holding event lock.Now i am doing like this Is that ok??

 

imageField = new BitmapField(Icon,BitmapField.FOCUSABLE)
{
protected boolean navigationClick(int status, int time)
{
try
{
synchronized (UiApplication.getEventLock())
{
NewCustomDialog dialog = new NewCustomDialog("successfully ", Field.FIELD_TOP, Color.BLACK);
UiApplication.getUiApplication().pushScreen(dialog);
Thread.sleep(4000);
}

}

catch(Exception e){}

}

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

Re: Problem in running networking application

you should spend a bit of time to understand the topic of the event thread.
this should help:
http://supportforums.blackberry.com/t5/Java-Development/What-is-the-Event-Thread/ta-p/446865

in the navigationClick method you are on the event thread. no need to use a sync on the event lock (which should not be used anyhow, in most cases invokelater is better).

Thread.sleep is also called on the event thread, this pauses all processing for four seconds. That means drawing the UI and listening for user input.
never do that.
----------------------------------------------------------
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
robert30
Posts: 191
Registered: ‎04-02-2013
My Device: BlackBerry Bold 9900
My Carrier: developer

Re: Problem in running networking application

Thanks Sir

Now i understood the difference.

 

Please use plain text.