Windows.Forms.Timer或System.Threading.Timer
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Windows.Forms.Timer或System.Threading.Timer相关的知识,希望对你有一定的参考价值。
我有一个运行许多线程的应用程序。每个线程都应该有一个计时器来检查该线程范围内的某些内容。我的问题是:我应该使用哪个计时器,它们之间有什么区别?
答案
本文提供了一个很好的比较,应该包含您需要的信息: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的主要内容,如果未能解决你的问题,请参考以下文章
简述System.Windows.Forms.Timer 与System.Timers.Timer用法区别
System.Windows.Forms.Timer没有触发
System.Windows.Forms.TimerSystem.Timers.TimerSystem.Threading.Timer