C# - 你如何停止计时器? [英] C# - how do you stop a timer?
本文介绍了C# - 你如何停止计时器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道这听起来很愚蠢,但我已经尝试了所有方法来停止计时器,但计时器不会停止.我正在开发一款游戏,如果有人能告诉我如何停止计时器,我将不胜感激.
I know it sounds stupid, but I've tried everything to stop a timer, but the timer won't stop. I'm working on a game and i would appreciate if someone could tell me how to stop a timer.
推荐答案
如果您使用 System.Timers.Timer
停止由以下选项之一执行:
If you are using System.Timers.Timer
stopping is performed by one of the options:
//options 1
timer.Enabled = false
//option 2
timer.Stop()
如果您使用的是System.Threading.Timer
,请使用此方法
if you are using System.Threading.Timer
, use this method
timer.Change(Timeout.Infinite , Timeout.Infinite)
如果您使用的是System.Windows.Forms.Timer
,请使用此方法
if you are using System.Windows.Forms.Timer
, use this method
timer.Stop();
这篇关于C# - 你如何停止计时器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文