Killing threads is horribly bad and not something anyone should do.  You
need to check in your task if it has been canceled, and return if so.

On Tue, Apr 20, 2010 at 2:04 PM, Nathan <[email protected]> wrote:

> Because it isn't.
>
> AsynTask.cancel(true) is called from a service on its AsyncTask
>
> It returns true.
>
> After the call, AsyncTask.iscancelled() is true.
>
> Nonetheless, the thread is still running happily and performing the
> tasks in doinBackground as if nothing had happened. I can see this all
> in the debugger.
>
> Any ideas? Is this a known issue?
>
> I see no evidence that this is working according to its documentation,
> below.
>
> Nathan
>
> public final boolean cancel (boolean mayInterruptIfRunning)
>
> Since: API Level 3
> Attempts to cancel execution of this task. This attempt will fail if
> the task has already completed, already been cancelled, or could not
> be cancelled for some other reason. If successful, and this task has
> not started when cancel is called, this task should never run. If the
> task has already started, then the mayInterruptIfRunning parameter
> determines whether the thread executing this task should be
> interrupted in an attempt to stop the task.
> Parameters
> mayInterruptIfRunning   true if the thread executing this task should be
> interrupted; otherwise, in-progress tasks are allowed to complete.
> Returns
> false if the task could not be cancelled, typically because it has
> already completed normally; true otherwise
>
> --
> 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]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>



-- 
Dianne Hackborn
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 
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

Reply via email to