计时器启动和启用的区别 [英] difference of start and enable in timers

查看:195
本文介绍了计时器启动和启用的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在计时器中启动和启用之间有什么区别?
什么是滴答事件?
我们如何为计时器设置值?(在特定时间运行计时器)

what is the difference between start and enable in timers?
what is a tick event?
how can we set a value to timers?(run the timer for a specific time)

推荐答案

C#中存在三种不同的计时器类:
There are three different timer classes in C#:

  • System.Threading.Timer;
    see http://msdn.microsoft.com/en-us/library/system.threading.timer.aspx[^];
  • System.Timers.Timer;
    see http://msdn.microsoft.com/en-us/library/system.timers.timer.aspx[^];
  • System.Windows.Forms.Timer;
    see http://msdn.microsoft.com/en-us/library/system.windows.forms.timer.aspx[^].

  1. 避免使用System.Windows.Forms.Timer;它使用起来最简单,但最不准确.其他两种类型需要使用System.Windows.Threading.DispatcherInvokeBeginInvoke方法(对于Forms或WPF)或System.Windows.Forms.Control(仅对于Forms).
    参见:
    http://msdn.microsoft.com/en-us/library/system. windows.threading.dispatcher.aspx [ ^ ],
    http://msdn.microsoft.com/en-us/library/system. windows.forms.control.aspx [ ^ ].
  2. 请务必避免使用计时器;
  3. 避免使用"{0}和{1}之间的区别是什么"形式的问题;它们不正确.

  1. Avoid using System.Windows.Forms.Timer; it simplest to use but is the most inaccurate. The other two types require to use the method Invoke or BeginInvoke of System.Windows.Threading.Dispatcher (for both Forms or WPF) or System.Windows.Forms.Control (Forms only).
    See:
    http://msdn.microsoft.com/en-us/library/system.windows.threading.dispatcher.aspx[^],
    http://msdn.microsoft.com/en-us/library/system.windows.forms.control.aspx[^].
  2. Avoid using timers by all means; use threads whenever possible.
  3. Avoid questions in the form "What''s the difference between {0} and {1}"; they cannot be correct.



—SA



—SA


这篇关于计时器启动和启用的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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