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
Regular Contributor
Posts: 59
Registered: ‎07-05-2010
My Device: Blackberry 9800
My Carrier: Airtel

AsyncTask in Blackberry

[ Edited ]

If anyone familiar with android developemnt, we know how good is AsyncTask utility for doing  Thread operations in backend while showing the Progress bar on front end.

 

Does anyone attempted to create a BlackBerry version of AsyncTask and ready to share??

 

Thanks in advance.

-Shankar
Developer
Posts: 604
Registered: ‎12-27-2010
My Device: Not Specified

Re: AsyncTask in Blackberry

All you need to do to work with the UI from a separate thread is to use the UiApplication.getUiApplication().invokeLater() method or synchronize on the UiApplication.getEventLock() and then you can update it. There are some details that you'll want to learn but that's the basic idea.

New Developer
Posts: 46
Registered: ‎12-16-2010
My Device: Not Specified

Re: AsyncTask in Blackberry

This isn't too hard basically you make a class that handles the thread. Progress bar which can be a custom component. As long as you have the threaded class give you info about what percent done it is, you can send that to the progress bar through a update type method. When the thread is done you can sent the response done as a callback method outside the thread that will close the progress bar.

 

So in other words

Call threaded class

Call progress bar (assuming it's a seperate screen), if not just enable updating of it.

Have Thread get updated percent complete

Sent that updated percent to progress bar which will repaint the screen

When finished have thread enter callback method

Stop updating progressbar/close screen

 

The reason I say use a seperate popup screen is you could push it modally and then you could block all other functions the user can do while your async task is running.

Trusted Contributor
Posts: 103
Registered: ‎11-07-2010
My Device: Not Specified

Re: AsyncTask in Blackberry

you can refer to ProgressIndicatorDemo found in BB demo applications.

Regular Contributor
Posts: 59
Registered: ‎07-05-2010
My Device: Blackberry 9800
My Carrier: Airtel

Re: AsyncTask in Blackberry

Sorry, my question might be unclear.

 

I did many applications which does the core IO operations on a seperate Thread while showing the Progress bar on UI thread.

 

When i see the Android AsyncTask, i feel more comfortable with the way it eases the Thread operations offering different methods for UI and Backend code and updating the Progress.

 

So, I just want to know whether anyone already ported the standard Android AsyncTask class into Blackberry environment or not?

-Shankar
Regular Contributor
Posts: 53
Registered: ‎06-29-2011
My Device: Blackberry 9800
My Carrier: o2

Re: AsyncTask in Blackberry

Hi Shankar,

Where you able to find a solution for this?
Am looking for a way to implement the Async Task in Blackberry.
BR,
Supriya
Developer
Posts: 75
Registered: ‎07-22-2011
My Device: curve 9300
My Carrier: New member

Re: AsyncTask in Blackberry

Hi did you get the solution for AsyncTask in Blackberry ?

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: AsyncTask in Blackberry

Have you looked at:

ProgressIndicatorDemo

Highlighted
Developer
Posts: 638
Registered: ‎07-02-2009
My Device: Not Specified

Re: AsyncTask in Blackberry

ProgressIndicatorDemo is a good one. If you want to go for rich UI handling then you can implement just like AsynTask in Android using callback methods. I don't think its big deal.. Smiley Happy
Thanks and Regards,
PraveenGoparaju.