如何检查是否所有AsyncTasks完了吗? [英] How to check if all AsyncTasks finished?
本文介绍了如何检查是否所有AsyncTasks完了吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有3个AsyncTasks和1个进度条。我想要的任何任务执行时,进度条是可见的,当所有的人都完成,进度条是不可见的。
I have 3 AsyncTasks and 1 ProgressBar. I want when any of task executes, the progress bar is visible and when all of them finish, the progress bar is invisible.
在Java中,还有的ExecutorService :: isTerminated,检查所有runables完成而Android却没有。
In Java, there is ExecutorService::isTerminated to check if all runables finished but Android doesn't.
更新:3个任务同时执行
Update: 3 tasks execute at the same time.
图。
Figure.
推荐答案
尼斯图形。但恐怕没有建立在mechanizm这一点。你必须自己去实现它。有几个解决方案,你可以使用 -
Nice graphic. But i am afraid there is no build in mechanizm for this. You'll have to implement it by yourself. There are few solutions you could use -
- 请参考所有3个任务。当如果对方两个任务完成之后也是如此,如果是比关闭进度对话框,如果没有等待其他一些任务来完成,并再次检查任务完成检查。确保你释放的引用时,即可大功告成。
- 如果你不想保持基准商店柜台。当任务完成增加计数器,并检查它是否等于3,如果是所有任务完成后,就大功告成了。如果实施此一定要同步的访问计数器。
这篇关于如何检查是否所有AsyncTasks完了吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文