经常调用 IntentService.startService()

发布于 2024-12-14 11:54:57 字数 260 浏览 0 评论 0原文

我想问一下,当

WakefulIntentService.sendWakefulWork()

或通常

IntentService.startService()

被调用时,是否存在类似意图溢出的情况,而不是等待以前的作业完成。我正在考虑一种情况,由于用户的输入,该作业可能需要 1 分钟,但每 10 秒调用一次。我是否应该实施任何机制来防止开始过多的工作?感谢您的所有回答

I would like to ask if there is something like intent overflow when

WakefulIntentService.sendWakefulWork()

or in general

IntentService.startService()

is called very often not waiting for previous jobs to be finished. I am thinking of a situation that due to user's input it might happen that the job takes 1 minute but it is called every 10 seconds. Should I implement any mechanism to protect from starting too many jobs? Thanks for all answers

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

最单纯的乌龟 2024-12-21 11:54:57

我应该实施任何机制来防止启动过多的作业吗?

如果您预计添加的作业会频繁超出已处理的作业,您应该考虑采取一些措施来帮助管理这种情况。虽然我不知道 OutOfMemoryError 之前有一个硬异常 - 除非你有一些相当大的 Intent 额外内容,但这里不太可能 - 你的 IntentService< /code> 将继续运行、运行、运行。在此过程中,它将消耗 CPU、RAM、可能的带宽(取决于工作内容)以及电池寿命。

Should I implement any mechanism to protect from starting too many jobs?

If you anticipate frequent stretches where your added jobs exceed the processed jobs, you should consider doing something to help manage that. While I am not aware of a hard exception before OutOfMemoryError -- which, unless you have some pretty big Intent extras, is rather unlikely here -- your IntentService will just keep running and running and running. Along the way, it will be chewing up CPU, RAM, possibly bandwidth (depending on what the work is), and hence battery life.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文