Windows.Forms.Timer 或 System.Threading.Timer [英] Windows.Forms.Timer OR System.Threading.Timer
本文介绍了Windows.Forms.Timer 或 System.Threading.Timer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个运行多个线程的应用程序.每个线程都应该有一个计时器来检查该线程范围内的某些内容.我的问题是:我应该使用哪个计时器,它们之间有什么区别?
I have an application that runs many threads. Each thread should have a timer that checks for something in that thread's scope. My question is: Which timer I should use and what is the difference between them?
推荐答案
这篇文章提供了一个很好的比较,应该包含您需要的信息:比较 .NET Framework 类库中的 Timer 类:
This article provides an excellent comparison and should contain the information you need: Comparing the Timer Classes in the .NET Framework Class Library:
Windows.Forms System.Timers System.Threading
Timer event runs on what thread? UI thread UI or worker thread Worker thread
Instances are thread safe? No Yes No
Familiar/intuitive object model? Yes Yes No
Requires Windows Forms? Yes No No
Metronome-quality beat? No Yes* Yes*
Timer event supports state object? No No Yes
Initial timer event schedulable? No No Yes
Class supports inheritance? Yes Yes No
* 取决于系统资源的可用性(例如工作线程)
* Depending on the availability of system resources (for example, worker threads)
这篇关于Windows.Forms.Timer 或 System.Threading.Timer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文