惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Visual Studio Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 聂微东
博客园 - 【当耐特】
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
C
Check Point Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
美团技术团队
WordPress大学
WordPress大学
Last Week in AI
Last Week in AI
Y
Y Combinator Blog
IT之家
IT之家
T
Tailwind CSS Blog
月光博客
月光博客
Vercel News
Vercel News
V
V2EX
Engineering at Meta
Engineering at Meta
B
Blog
Stack Overflow Blog
Stack Overflow Blog
A
About on SuperTechFans
Hugging Face - Blog
Hugging Face - Blog
人人都是产品经理
人人都是产品经理
腾讯CDC
I
InfoQ

博客园 - John Rambo

定时关机脚本 Mean shift算法处理图像(Scilab & C#) Arimoto–Blahut algorithm (Mathematica) 1分钟搞定QuickSort算法 C#行列式计算程序 MIDL语法详解 (译) Virtual PC2007 + Redhat9下的网络配置 关于IFromatterProvider Total KMP 分析函数调用的汇编指令 why c++/cli About double-checked locking 对透明代理源码的一些理解 ReaderWriterLockSlim CallContext类 GDI+ is F**king unbelievable 第一个Postsharp插件 WeakReference System. ThreadStaticAttribute
A better timer
John Rambo · 2008-11-16 · via 博客园 - John Rambo

Windows forms中自带的Timer控件据说精度只有55ms。又有传说在Winnt 4.0以上精度可以达到10ms。

不知道为什么已经没有心情再去考证到底是怎么回事,决定自己写一个:

Code

效果:

可以看到刷新率可以达到90桢每秒。

不过我遇到了一个很奇怪的问题,关于Thread.Sleep。当指定的间隔小于10000tick的时候,cpu占用就接近100%,但是只要达到了10000tick,cpu占用立刻就变成0%。不知道是为什么。可能是因为当小于10000tick的时候是用自旋锁实现,大于等于10000tick的时候是用另外的方式实现的。

另外一个十分棘手的问题是屏幕闪烁。在Form上指定的ControlStyle后,仍然有一定的闪烁,难道GDI+的性能就这么成问题?

完整的代码:/Files/zhy2002/GDIPlusMovable.rar