C# 中是否有一个不在 Windows.Forms 命名空间中的计时器类? [英] Is there a timer class in C# that isn't in the Windows.Forms namespace?

查看:13
本文介绍了C# 中是否有一个不在 Windows.Forms 命名空间中的计时器类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我用 C# 编写的简单 .NET 应用程序中使用计时器.我能找到的唯一一个是 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屋!

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