Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have use AsyncTask for Fetch data for Sql Server,so that i have create multiple time
AsyncTask ex: new MyAsyncTask().execute(new String[]{"...."});
My Question is:
It is Needed to kill or terminate AsyncTask in AndroidApplication?
If yes than How?
Posted

1 solution

No, it is not needed to kill or terminate an asyncTask in any way, it should be garbage collected upon job finish (and send/retrieve the results back from the main thread via onPostExecute).

I've used asyncTask to download thumbnails for lists over 1000 elements long, and never had a problem.

However, it is a good practice to implement onCancelled method, and handle whatever it is the asyncTask is/was doing when cancelled (i.e. you have a download in progress, and the user cancels the download. What do you do then?)
 
Share this answer
 
v2
Comments
Rajesh Sanandiya 5-Sep-12 0:49am    
Thank you....
Andrei Straut 5-Sep-12 2:05am    
If it helped, then please upvote the solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900