System.Windows.Forms.Timer性能 [英] System.Windows.Forms.Timer performance

查看:268
本文介绍了System.Windows.Forms.Timer性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个包含了很多用户的应用控制了更新频繁基于一个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.

这篇关于System.Windows.Forms.Timer性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆