有没有在C#中的计时器类,是不是在Windows.Forms的命名空间? [英] Is there a timer class in C# that isn't in the Windows.Forms namespace?
问题描述
我想在我的简单 .NET应用 C#编写的使用计时器。唯一一个我能找到的是Windows.Forms.Timer类。我不想引用该命名空间只是为我的控制台应用程序。
I want to use a timer in my simple .NET application written in C#. The only one I can find is the Windows.Forms.Timer class. I don't want to reference this namespace just for my console application.
有没有C#计时器(或定时器等)类控制台应用程序中使用?
Is there a C# timer (or timer like) class for use in console applications?
推荐答案
System.Timers.Timer
System.Timers.Timer
作为MagicKat说和:
And as MagicKat says:
的System.Threading .Timer
System.Threading.Timer
您可以在这里看到的区别:
的 http://intellitect.com/system-windows-forms-timer-vs-system-threading-timer-vs-system-timers-timer/
You can see the differences here: http://intellitect.com/system-windows-forms-timer-vs-system-threading-timer-vs-system-timers-timer/
你可以在这里看到MSDN例子:
And you can see MSDN examples here:
的http://msdn.microsoft.com/en-us/library/system.timers.timer(VS。 80)的.aspx
这里:
的http://msdn.microsoft.com/en-us/library/system.threading.timer(VS。 80)的.aspx
这篇关于有没有在C#中的计时器类,是不是在Windows.Forms的命名空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!