C#:是有一个相当于类的TimerTask的从Java在C#中? [英] C#: is there an equivalent class of TimerTask from Java in C#?
问题描述
我要寻找是否有从Java在C#中的等价类的TimerTask的
I am looking if there is an equivalent class of TimerTask from Java in C#?
的Java的TimerTask的被引用到这里:的 http://download.oracle.com/javase/1.4.2/docs/ API / JAVA / UTIL / TimerTask.html
The TimerTask of Java is referenced to here: http://download.oracle.com/javase/1.4.2/docs/api/java/util/TimerTask.html
先谢谢了。
的目的这是我需要实现在C#下面的代码:
The purpose of this is that I need to implement some code following in C#:
import java.util.Timer;
import java.util.TimerTask;
private static Timer timer = new Timer();
private TimerTask timeoutTask;
if (timeoutTime>0)
{
timeoutTask = new TimerTask() {
public void run()
{
// callActivity();
}
};
}
timer.schedule( timeoutTask, timeoutTime);
如果你能提供给我在C#中的等价代码,那将是伟大的!在此先感谢
If you could provide me an equivalent code in C#, that would be great! Thanks in advance
推荐答案
听起来像的 System.Timers.Timer
。有四种通用定时器类型.NET:
Sounds like System.Timers.Timer
. There are four common timer types in .NET:
-
System.Windows.Forms.Timer
中的WinForms应用计时器 -
System.Windows.DispatcherTimer
在WPF / Silverlight应用程序定时器 -
System.Threading.Timer
-
System.Timers.Timer
System.Windows.Forms.Timer
for timers in WinForms appsSystem.Windows.DispatcherTimer
for timers in WPF/Silverlight appsSystem.Threading.Timer
System.Timers.Timer
本文比较所有,但DispatcherTimer。
This article compares all but DispatcherTimer.
这篇关于C#:是有一个相当于类的TimerTask的从Java在C#中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!