在.NET应用程序定时器定时器、应用程序、NET

由网友(酒味泡芙)分享简介:我想知道什么样的定时器可在C#应用程序中使用,哪些是cuncurrency在多线程环境中的长期其影响。你能解释我或链接我的esaustive教程?谢谢你。I would like to know what kind of timers can be used in a C# application and wha...

我想知道什么样的定时器可在C#应用程序中使用,哪些是cuncurrency在多线程环境中的长期其影响。 你能解释我或链接我的esaustive教程? 谢谢你。

I would like to know what kind of timers can be used in a C# application and what are their implications in term of cuncurrency in a multi-threaded environment. Could you explain me or link me to an esaustive tutorial? Thank you.

推荐答案

有两种形式的计时器 - 那些是基于消息的,通常用户界面为中心,而那些是基于线程的

There are two forms of timers - ones that are message based, and typically UI centric, and ones that are thread-based.

用户界面版本是从Windows窗体 Timer类或 DispatcherTimer在WPF 。这些倾向报告时序(正常)在UI线程上,基本上使用标准的消息泵来处理时机。

The UI versions are the Timer class from Windows Forms or the DispatcherTimer in WPF. These tend to report timings (normally) on the UI thread, and basically use the standard message pump to handle timing.

借助 System.Timers.Timer的和< A HREF =htt​​p://msdn.microsoft.com/en-us/library/system.threading.timer.aspx相对=nofollow> System.Threading.Timer 类用于处理一个单独的线程计时器。这些工作非常好,但嘀的事件发生在一个单独的线程。这意味着你需要处理线程同步或UI线程同步,如果你使用这些。

The System.Timers.Timer and System.Threading.Timer classes use a separate thread for handling timers. These work very well, but the "Tick" events happen on a separate thread. This means you need to handle thread synchronization or UI threading synchronization if you use these.

阅读全文

相关推荐

最新文章