计时器启动和启用的区别 [英] difference of start and enable in timers
本文介绍了计时器启动和启用的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在计时器中启动和启用之间有什么区别?
什么是滴答事件?
我们如何为计时器设置值?(在特定时间运行计时器)
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#中存在三种不同的计时器类:
System.Threading.Timer
;
请参见 http://msdn.microsoft.com /en-us/library/system.threading.timer.aspx [ ^ ];System.Timers.Timer
;
请参见http://msdn.microsoft.com/en-us/library/system.timers.timer.aspx [ http://msdn.microsoft.com/en-us/library /system.windows.forms.timer.aspx [
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[^].
- 避免使用
System.Windows.Forms.Timer
;它使用起来最简单,但最不准确.其他两种类型需要使用System.Windows.Threading.Dispatcher
的Invoke
或BeginInvoke
方法(对于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 [ ^ ]. - 请务必避免使用计时器;
- 避免使用"{0}和{1}之间的区别是什么"形式的问题;它们不正确.
- Avoid using
System.Windows.Forms.Timer
; it simplest to use but is the most inaccurate. The other two types require to use the methodInvoke
orBeginInvoke
ofSystem.Windows.Threading.Dispatcher
(for both Forms or WPF) orSystem.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[^]. - Avoid using timers by all means; use threads whenever possible.
- Avoid questions in the form "What''s the difference between {0} and {1}"; they cannot be correct.
这篇关于计时器启动和启用的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文