[英]Delegate / Timer - Method (misunderstanding?)
There's many questions and articles on timer scripts, but oddly enough, I haven't succeeded in uh, this one. 关于计时器脚本有很多问题和文章,但奇怪的是,我还没有成功完成这个任务。 Is it just (?) a simple delegate - timer.
仅仅是(?)一个简单的委托者-计时器。 I would post errors but it is probably a rough understanding of the timing class.
我会发布错误,但这可能是对计时类的粗略了解。
class Core
{
private static System.Timers.Timer systimer, sysupdate;
delegate void MyDelegate(string s);
public static void Main(string[] args)
{
Core dtimer = new FunctionTimer();
Core dupdate = new Update();
TimerCallback tcb1 = Core.FunctionTimer;
TimerCallback tcb2 = Core.Update;
systimer = new Timer(tcb1, null, 0, 1);
sysupdate = new Timer(tcb2, null, 0, 1);
}
}
I'm assuming the actual methods are sort of irrelevant.. 我假设实际的方法无关紧要。
1) create new instance of a timer, pass in millisecond duration 1)创建计时器的新实例,以毫秒为单位传递
systimer = new Timer( 10 * 60 * 1000 ); // 10 minutes
2) hookup event handler (delegate) to execute when duration elapses 2)连接事件处理程序(委托)在持续时间过去时执行
systimer.Elapsed += new ElapsedEventHandlder( nameOfHandler );
3) start timer 3)启动计时器
systimer.Start();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.