Monday, May 20, 2024
Homepage · c#
 Popular · Latest · Hot · Upcoming
33
rated 0 times [  37] [ 4]  / answers: 1 / hits: 15321  / 12 Years ago, sat, november 10, 2012, 12:00:00

How to use setTimeout() and setInterval method in C# with Script#?



For example, how to write: setInterval(function(){alert(Hello)},3000); ?


More From » c#

 Answers
181

SetTimeout() and SetInterval() are part of the Script class (or Window for previous versions of Script# < 0.8). You use them like this with an inline delegate:



int intervalid = Script.SetInterval(delegate { Window.Alert(Hello); }, 3000);


Or you can write an explicit handler function:



Script.SetTimeout(TimeoutHandler, 3000);

void TimeoutHandler() {
Window.Alert(Hello);
}


To discard the timer interval later you can use ClearInterval():



Script.ClearInterval(intervalid);

[#82060] Friday, November 9, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
irvingcarloe

Total Points: 677
Total Questions: 109
Total Answers: 96

Location: Svalbard and Jan Mayen
Member since Sun, Sep 25, 2022
2 Years ago
irvingcarloe questions
Wed, Mar 31, 21, 00:00, 3 Years ago
Tue, Aug 4, 20, 00:00, 4 Years ago
Fri, Jul 3, 20, 00:00, 4 Years ago
;