System.Windows.Forms.Timer性能性能、Windows、System、Timer

由网友(陪你看日出)分享简介:我们有一个包含了很多用户的应用控制了更新频繁基于一个System.Windows.Forms.Timer。我是安全的Timer实例添加到每个控制peformancewise?或者我应该有一个运行所有要使用的所有实例的时间辛格尔顿计时器?什么是引擎盖下实际上可以发生?会不会有一个额外的线程(计数)每个定时器?We ha...

我们有一个包含了很多用户的应用控制了更新频繁基于一个System.Windows.Forms.Timer。我是安全的Timer实例添加到每个控制peformancewise?或者我应该有一个运行所有要使用的所有实例的时间辛格尔顿计时器?什么是引擎盖下实际上可以发生?会不会有一个额外的线程(计数)每个定时器?

We have an application containing a lot of user controls that update frequently based on a System.Windows.Forms.Timer. Am I safe to add a Timer instance to each control peformancewise? Or should I have one Singleton Timer that runs all the time that is to be used by all instances? What is acutally happening under the hood? Will there be a an additional thread (for counting) for each timer?

推荐答案

有没有额外的线程。刚才有很多WM_TIMER消息进来的线程的消息队列中。因此,这些计时器将不执行他们的code平行,即使其时间跨度重叠。

There is no additional thread. There are just a lot of WM_TIMER messages coming in your thread's message queue. So these timers won't execute their code in parallel, even if their timespans overlap.

我认为它不会伤害有埃维控制一个单独的计时器。至少它肯定不会比使用单一的计时器任何可测量的性能差异。在code将获得更具可读性,但。 ;)

I think that it wouldn't hurt to have a separate timer for evey control. At least it definately won't have any measureable performance difference over using a single timer. The code will get more readable though. ;)

顺便说一句 - 与今天的大规模转移到多个CPU内核,考虑是否这也许不是一个地方,你可以从中受益。

Btw - with todays massive move to multiple CPU cores, consider if this perhaps isn't a place where you can benefit from it.

阅读全文

相关推荐

最新文章