Call a method regularly

Source: Internet
Author: User

In form, you can call the setTimeout method of formrun to call a method on a regular basis. But how does one implement a common class instead of a form?
1. cache the current object in the global cache.

Server Static   Void Main (ARGs _ ARGs)
{
Testclass= NewTestclass ();
Sysglobalcache=Infolog. globalcache ();
;
Cache.Set(Classstr (testclass ),"Hellotestclass", Testclass );
Testclass. testmethod ();

}

2. Call testmethod regularly using the addtimeout method of the infolog object Void Testmethod ()
{
;
This . Parmtimehandler (infolog. addtimeout ( This , Methodstr (testtimeout, testmethod ), 1000 , False ));
If (I = 10 )
Infolog. removetimeout ( This . Parmtimehandler ());
I ++ ;

Info (int2str (I ));
}

in this way, testmethod is called once every 1 s until the call reaches a specified number of times. The specific call is implemented through the calltimeout method of the info class, however, it is unknown when the calltimeout method is called.
definition of this class: class testclass extends Object
{< br> int timehanlder;
int I;
}

parmtimehandler method: int parmtimehandler ( int _ timehanlder = timehanlder)
{< br>;
timehanlder = _timehanlder;
return timehanlder;
}

because infolog is a client object, if the called method is a server object, it increases the number of interactions between the client and the server, but does not know how to implement regular calls on the server.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.