开发者

Windows.Forms.Timer OR 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开发者_StackOverflow中文版 scope. My question is: Which timer I should use and what is the difference between them?


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)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜