Re: [android-developers] Re: one AsyncTask at a time
On Sat, Sep 10, 2011 at 10:13 AM, bob <bob@coolgroups.com> wrote:
> That's a possibility. Or, I might use this function I wrote:
>
> void replaceCurrentTask(android.os.AsyncTask<Void, Void, Long>
> newTask){
> if (currentTask != null) {
>
> currentTask.cancel(true);
> while (!currentTask.isCancelled() && currentTask.getStatus()!
> =AsyncTask.Status.FINISHED) trytosleep(1);
> }
>
> currentTask=newTask;
> currentTask.execute();
>
> }
Yuck.
Use a LinkedBlockingQueue and your own thread working jobs off of that
queue, rather than AsyncTask.
--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy
_The Busy Coder's Guide to *Advanced* Android Development_ Version 2.0
Available!
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home