AsyncTask的大量使用 [英] Asynctask heavy usage

查看:100
本文介绍了AsyncTask的大量使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

的AsyncTask的设计是围绕线程和处理程序一个辅助类,并不构成的通用线程框架。   AsyncTasks最好应用于短操作(在几秒钟   在最。)

AsyncTask is designed to be a helper class around Thread and Handler and does not constitute a generic threading framework. AsyncTasks should ideally be used for short operations (a few seconds at the most.)

这就是它说的文件中。

在谈到网络语言,多长时间是几秒钟?

Speaking network language, How long is 'a few seconds'?

我的应用程序将执行以下操作,获取一个数组列表从数据库,将其发送给服务器,获得另一个列表(JSON),发送一个不错的,它收到的名单,解析jsons,将里面的数据库列表,做一些在db等工序,更新UI。(名单可达对象实例的5000-1000项。)

My app will do the following, get an array list from DB, send it to server, get another list (json), send an okay that it received the list, parse the jsons, insert the list inside db, do some other processes in the db, update UI.. (the list can reach to 5000-1000 entries of object instances.)

时使用的AsyncTask对这种东西是个好主意?我还需要根据来自服务器的响应的结果来更新GUI。

Is usage of asynctask for such stuff a good idea? I also need to update the gui according to the results of the response from server.

如果没有,我有什么其他选择?

If no, what other alternatives do I have?

推荐答案

我已经做了类似你的东西。我已经下载了一堆图像(约5000),将它保存在SD卡并保存一行在数据库中。 我已经使用了异步任务,没有问题,我用它看不出有什么问题。我建议你​​使用一个进度条来显示什么应用程序在做用户的选项取消任务(AsyncTask的提供了一个取消机制)

I've already did something similar to you. I've downloaded a bunch of images (about 5000), saved it in the SD card and saved a row in a database. I've used Async Task with no issues and I see no problem using it. I recommend you to use a progress bar to show the user what the App is doing and with the option to cancel the task (AsyncTask provides a cancelation mechanism)

这篇关于AsyncTask的大量使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆