问题描述
假设我们有它运行,每10分钟的计时器。如果其加工的周期时间超过10分钟。难道一个新的线程开始是什么?它会中断其当前操作?如果有什么单一的对象是在计时器内突变?
Suppose we have a timer which runs every 10 minutes. What if the cycle of its processing takes more than 10 minutes. Does a new thread starts for that? Will it interrupt its current operation? What if a single object is mutated inside the timer?
很抱歉,如果我不提了,任何代码,因为这个问题是清楚的,也是我想知道完整的答案从多线程编程怪胎的角度出发,而不是尝试通过一个示例应用程序来测试它找到一个松散的答案。其实,我想知道它背后的工作机制的逻辑。
Sorry if I do not mention any code for that because the problem is clear and also I want to know the complete answer from the viewpoint of a multi-threaded programming geek rather than finding a loose answer by trying to test it via a sample application. Actually, I want to know the logic behind its working mechanism.
推荐答案
如果你使用系统.Threading.Timer
或 System.Timers.Timer
,计时器会再次打勾,开始一个新的线程。请参见一种方式来避免这样的问题。
If you're using System.Threading.Timer
or System.Timers.Timer
, the timer will tick again, starting a new thread. See http://stackoverflow.com/a/10442117/56778 for a way to avoid that problem.
如果你使用 System.Windows.Forms.Timer
,那么会不会出现一个新的刻度,直到前一个是成品加工。
If you're using System.Windows.Forms.Timer
, then a new tick won't occur until the previous one is finished processing.
这篇关于如果新的周期到来之前的计时器不能完成所有的工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!