定时调用某个方法

在Form中可以调用FormRun的setTimeOut方法,实现定时调用某个方法,但如何是一般的类,不是窗体,该如何实现那?
1.在全局缓存中缓存当前对象.

server static void Main(Args _args)
{
    TestClass testClass 
= new TestClass();
    SysGlobalCache  cache 
= infolog.globalCache();
    ;
    cache.
set(classstr(TestClass),"HelloTestClass",testClass);
    testClass.testMethod();

}
2.使用infolog对象的addTimeOut方法定时调用testMethod
void testMethod()
{
    ;
    
this.parmtimeHandler(infolog.addTimeOut(this,methodstr(TestTimeout,TestMethod),1000,false));
    
if(i==10)
        infolog.removeTimeOut(
this.parmtimeHandler());
    i
++;
    
    info(int2str(i));
}
这样testMethod会被每隔1s调用一次,直到调用到达指定次数,具体的调用是通过info类的callTimeOut方法实现的,但至于什么时候调用callTimeOut方法就不得而知了.
该类的定义:
class TestClass extends object
{
    
int timeHanlder;
    
int i;
}
parmtimeHandler方法:
int parmTimeHandler(int _timeHanlder = timeHanlder)
{
    ;
    timeHanlder 
= _timeHanlder;
    
return timeHanlder;
}

由于infolog是客户端对象,如果被调用的方法是服务器端对象会增加客户端和服务器端的交互次数,但不晓得如何实现在服务器端的定时调用.
原文地址:https://www.cnblogs.com/Farseer1215/p/1123910.html