Windows Forms Timer C#tick事件在不同的计算机上有什么不同?

时间:2021-12-07 00:02:35

I have a program that is a Windows Forms C# .NET 4.0 Framework Client Profile. The only thing it does is update a bitmap image on a Quicktime control on the form every 5500 milliseconds using a windows form timer. On my development laptop I am using System 8.1 and it is an i7 processor with a SSD drive. I am using VS 2012. I am using the .NET Stopwatch object to time my events on my development laptop. On my laptop with the forms timer set to 5500 I get tick events very close to 5500 ms with +/- 15 ms accuracy which is more than good enough (I'd be satisfied with 50 ms accuracy).

我有一个Windows Forms C#.NET 4.0 Framework Client Profile程序。它唯一能做的就是使用Windows窗体定时器每隔5500毫秒在窗体上的Quicktime控件上更新一个位图图像。在我的开发笔记本电脑上,我使用的是System 8.1,它是带有SSD驱动器的i7处理器。我正在使用VS 2012.我正在使用.NET Stopwatch对象来计算我的开发笔记本电脑上的事件。在我的笔记本电脑上,窗体定时器设置为5500,我得到非常接近5500 ms的刻度事件,精度为+/- 15 ms,这已经足够好了(我对50 ms精度感到满意)。

When I run the exact same program on the production computers which are i3 and i5 processors and System 7 windows machines the tick event is always 5700 ms with +/- 15 ms accuracy - in other words the tick event is always 200 ms long, but still always very exactly 200 ms long with +/- 15ms accuracy, it is almost like the timer interval is set to 5700 ms on the production machines - but it is the same code?

当我在i3和i5处理器以及System 7 windows机器的生产计算机上运行完全相同的程序时,tick事件总是5700 ms,准确度为+/- 15 ms - 换句话说,tick事件总是200 ms,但是仍然总是非常精确地200毫秒,精度为+/- 15ms,它几乎就像生产机器上的定时器间隔设置为5700毫秒 - 但它是相同的代码?

Does anyone have any ideas on how this could be possible and where to look for why this is occurring?

有没有人对如何做到这一点有任何想法,以及在哪里寻找为什么会这样?

1 个解决方案

#1


0  

System.Windows.Forms.Timer may not be your best option since it only runs on your UI thread at idle time. System.Timers.Timer or System.Threading.Timer could overall give you better results with less dependency to processor speed. See this article for more detailed comparison.

System.Windows.Forms.Timer可能不是您的最佳选择,因为它只在空闲时在您的UI线程上运行。 System.Timers.Timer或System.Threading.Timer可以总体上为您提供更好的结果,同时减少对处理器速度的依赖。有关更详细的比较,请参阅此文章。

#1


0  

System.Windows.Forms.Timer may not be your best option since it only runs on your UI thread at idle time. System.Timers.Timer or System.Threading.Timer could overall give you better results with less dependency to processor speed. See this article for more detailed comparison.

System.Windows.Forms.Timer可能不是您的最佳选择,因为它只在空闲时在您的UI线程上运行。 System.Timers.Timer或System.Threading.Timer可以总体上为您提供更好的结果,同时减少对处理器速度的依赖。有关更详细的比较,请参阅此文章。