问题标签 [periodic-task]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
132 浏览

android - 定期调用网络以仅在前台进行任何更新

我想定期检查每 30 秒进行一次网络调用的更新并相应地更新列表视图,前提是我的屏幕处于前台(因此不是来自服务)。我为此做的是——

但是,这会在滚动时挂起我的列表。

我该怎么做?

0 投票
3 回答
854 浏览

android - Android:运行具有不同睡眠间隔的周期性任务

我正在构建一个 Android 应用程序,它应该在后台通过网络从服务器获取定期更新。

响应是一个 JSON 对象,其中包含数据和直到下一次更新的间隔:

我希望应用程序在nextUpdateIntervalSeconds. 在此示例中,应在一小时后获取下一次更新。如果网络调用不成功,nextUpdateIntervalSeconds则应使用默认值。

如何在 Android 中运行具有不同睡眠时间的周期性任务?

0 投票
1 回答
337 浏览

windows-phone-8 - 开启节电模式时后台代理不运行

我正在使用可以完美运行的 PeriodicTask,但如果开启了省电模式,它就不会运行,即使我已经通过 Battery Saver 应用程序允许该应用程序在此状态下在后台运行。

任何想法可能导致它无法运行?我应该补充一点,我正在使用后台代理中的 Telerik 的 LiveTileHelper 控件生成一个新的前后动态磁贴图像,并且还发出了一个 http 请求(该应用程序是一个天气应用程序)。这是针对 Silverlight Windows Phone 8 应用程序的。

很抱歉这个问题很笼统,但我假设解释不需要我共享代码。

任何见解将不胜感激。

巴迪

0 投票
1 回答
880 浏览

python - 有没有可能在 Celery 中创建动态周期性任务的方法?

我想从 celery 调度程序中添加和删除定期任务,但是我没有找到一种简单的方法来做到这一点。可能吗?

我找到了下一个问题,但我想知道是否有不使用 Django 的替代方案。 如何向 Celery (celerybeat) 动态添加/删除周期性任务

0 投票
1 回答
86 浏览

java - 如何从应用程序开始运行固定间隔线程?

这可能是一个措辞不佳的标题,但我试图从一开始就收集有关我的应用程序的数据和统计信息。我正在使用 JavaFX,并且我有一个模型类将处理所有数据和处理。

我想要的是该模型类从应用程序启动的那一刻开始收集数据(如运行时、线程数、内存使用量......)。但我也希望它每秒不断更新这些值,这意味着我需要它在某种 ScheduledExecutorThread 或其他东西上运行。

我怎样才能做到这一点,从这个程序的一开始,模型类就会每秒运行一次“update()”函数?

0 投票
1 回答
116 浏览

windows-phone-8 - 用于 Windows Phone 应用程序的单独后台代理,以独立更新动态磁贴 + 锁定屏幕

这可能吗?还是 Windows Phone 8 应用程序仅限于单个后台代理?

我目前有一个后台代理更新活动磁贴,并且正在推动适用于定期任务的内存限制。如果/当我添加锁定屏幕支持时,锁定屏幕也需要在后台更新,这必须通过相同的定期任务来实现,还是我可以运行单独的后台代理来更新锁定屏幕?

巴迪

0 投票
2 回答
1554 浏览

visual-c++ - Limits of Windows Queue Timers

I am implementing a timer and need it to run every 50 ms or so and would like the resolution to be 1 ms or less. I started by reading these two articles:

http://www.codeproject.com/Articles/1236/Timers-Tutorial

http://www.virtualdub.org/blog/pivot/entry.php?id=272

Oddly enough they seem to contradict one another. One says queue timers are good for high resolution, the other posts results from a Windows 7 system showing resolution around 15ms (not good enough for my application).

So I ran a test on my system (Win7 64bit i7-4770 CPU @3.4 Ghz). I started at a period of 50ms and this is what I see (time since beginning on left, gap between executions on right; all in ms):

I see that the maximum error is about 100 us and that the average error is probably around 30 us or so. This makes me fairly happy.

So I started dropping the period to see at what point it gets unreliable. I started seeing bad results once I decreased the period <= 5ms.

With a period of 5ms it was not uncommon to see some periods jump between 3 and 6ms every few seconds. If I reduce the period to 1ms periods of 5 to 10 to 40 ms can be seen. I presume that the jumps up to 40ms may be due to the fact that I'm printing stuff to the screen, I dunno.

This is my timer callback code:

Anyways it looks to me as if queue timers are very good tools so long as you're executing at 100hz or slower. Are the bad results posted in the second article I linked to (accuracy of 15ms or so) possibly due to a slower CPU, or a different config?

I'm wondering if I can expect this kind of performance across multiple machines (all as fast or faster than my machine running 64bit Win7)? Also, I noticed that if your callback doesn't exit before the period elapsed, the OS will put another thread in there. This may be obvious, but it didn't stand out to me in any documentation and has significant implications for the client-code.

0 投票
1 回答
160 浏览

windows-phone-8 - 使用 Windows Phone 8 每 5 分钟在后台跟踪地理位置

我想每隔 5 分钟获取一次地理位置,它应该使用 Windows Phone 8 SDK 在后台运行。

我一直在考虑使用定期任务,但它以 20 分钟的间隔运行,这不够频繁。我可以通过使用更频繁地运行它

ScheduledActionService.LaunchForTest(periodicTaskName, TimeSpan.FromSeconds(300));

但我认为当我想在市场上发布这个应用程序时,这不会受到欢迎。

然后我检查了连续跟踪位置,但它不会停止使用 gps 传感器,除非您手动停止它。

我将不胜感激任何能引导我实现目标的指导。

谢谢你的帮助。

0 投票
1 回答
733 浏览

java - 定期通知多个线程

我正在开发一个使用原始 Java 并发结构的项目,例如 wait()、notify()、notifyAll()、Thread.run()、synhronized 等。在我的项目中,有多个线程(Thread 类的扩展) 谁会定期从队列中获取对象。因此,我使用了一个具有内部 TimerTask 类的 Timer 类。

我的问题是,我无法让其他线程定期唤醒。我的主要课程不是这些线程或计时器类。因此,我称他们从另一个班级运行。我不知道如何让这些线程每 100 毫秒等待并通知一次。我的计时器课程是:

我的线程类是:

现在,我真的很困惑如何定期释放线程类。我什至无法确定是否使用 wait()/notify()。

正如我之前所说,我将创建多个 Element 类。他们将同步工作。那么,我该怎么办?

0 投票
1 回答
843 浏览

task - Celery task monitoring inside periodic Task

I'm using celery inside a django project, i have a celery scheduled task that run every minute and check inside a db if there is a new task to start, and also the task configured has a time start and duration.

The job of this periodic task is:

  • Start a new async task if there is a newone configured. (task.delay(...))
  • Check if a task previous started is running
  • Stop task that exceed its duration (app.control.revoke(...))
  • .... and other stuff...

But the question is: What is the "best practice" to monitor the status of started async task inside a periodic task?

I mean everytime the sceduled task run, i get from DB all the configured task (started, to start....) but i don't have the related celery task id associated to it, should i store celery task id inside db, to have the db task associated to the related task celery running?

Could django-celery help me?

Thanks.