C#:是有一个相当于类的TimerTask的从Java在C#中? [英] C#: is there an equivalent class of TimerTask from Java in C#?

查看:264
本文介绍了C#:是有一个相当于类的TimerTask的从Java在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 apps
  • System.Windows.DispatcherTimer for timers in WPF/Silverlight apps
  • System.Threading.Timer
  • System.Timers.Timer

本文比较所有,但DispatcherTimer。

This article compares all but DispatcherTimer.

这篇关于C#:是有一个相当于类的TimerTask的从Java在C#中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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