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
you can stop like this
timer.Enabled = false
如果您使用的是 System.Threading.Timer
,使用
timer.Change(Timeout.Infinite , Timeout.Infinite)
或者使用
timer.Stop();
如果您使用的是 System.Windows.Forms.Timer
这篇关于C# - 你怎么停止计时器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文