在.NET应用程序定时器 [英] Timers in a .NET application

查看:145
本文介绍了在.NET应用程序定时器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道什么样的定时器可在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.

这篇关于在.NET应用程序定时器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆