zoukankan      html  css  js  c++  java
  • 定时调用某个方法

    在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是客户端对象,如果被调用的方法是服务器端对象会增加客户端和服务器端的交互次数,但不晓得如何实现在服务器端的定时调用.
  • 相关阅读:
    pycharm下同存Python2和Python3的运行方式问题
    Python3安装requests库
    jmeter实现接口传参为一个文件的测试场景
    解决jmeter添加HTTP Cookie Manager后,还是cookie错误的问题
    jmeter添加webSocket请求
    sublime集成Python环境
    jmeter实现排除登录对单个事务的压测
    JavaScript语法
    JavaScript数据
    javaScript基础
  • 原文地址:https://www.cnblogs.com/Farseer1215/p/1123910.html
Copyright © 2011-2022 走看看