I know how to use AsyncTask in a standard manner to manage operations
that are in the background in relation to a UI thread.

However, I want to run a task in the background which might run for a
very long time under certain circumstances. In these cases, I would
like to force the background task to fail if it runs for an excessive
amount of time.

I know that I can invoke the "get(long timeout, TimeUnit unit)" method
of AsyncTask in my UI thread in order to terminate my background task
if it runs too long. However, in that case, my UI will block while
this "get()" command is waiting.

There are probably other drawbacks to directly calling "get()" in this
manner, not the least of which being an evil interaction with the
"done()" method of AsyncTask's contained FutureTask object, which
itself is calling "get()" -- at least this is what I see when I look
at the source code for AsyncTask.

So what is the canonical, Android-approved method for timing out an
overly-long-running AsyncTask?

Thanks in advance.




-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe, reply using "remove me" as the subject.

Reply via email to