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
Posts: 105
Registered: ‎06-23-2010
My Device: 9000
My Carrier: vodaphone

Internet Access and Threads

All:

Is there a good example out there where this is shown? What I am interested in is a class (set of classes) that allow you to post a request and then "wait" for the result. I have an app that does a variety of things with web services and keeping this all threaded properly is a bit of a challenge...

 

I realize that all the internet stuff cannot run on the main event thread...

 

-matt

-matt

Press Kudos if this helped - ;-)
Developer
Posts: 17,012
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Internet Access and Threads

most of the time i use a callback structure to notify my UI about new results.

you can use a new thread for each request, or, i bigger structures, use a runnablequeue.

----------------------------------------------------------
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
Regular Contributor
Posts: 98
Registered: ‎08-31-2010
My Device: BB-9700
My Carrier: Airtel

Re: Internet Access and Threads

To create a well defined structur,  you can use this approach:

 

Create HTTPCommunicationInterface class which would have methods like StartRequest, CancelRequest

Create HTTPCommunicationImplementation which implements HTTPCommunicationInterface and Runnable. In this constructor, you can create a new thread object, and in overwrite method StartRequest- you can start the thread. In the run method you can actually write SendPostRequest method, which will run in seperate thread without interupting main event thread.

 

Thanks

 

Regards

-Abhijit

Developer
Posts: 105
Registered: ‎06-23-2010
My Device: 9000
My Carrier: vodaphone

Re: Internet Access and Threads

Gents:

I ended up using the ObserverInterface...works great.

 

 

-matt

Press Kudos if this helped - ;-)