I´m developing a C# project using JINT (https://github.com/sebastienros/jint), and I need to create a timer on my JS so it can execute a function on my javascript every time the timer tim set is elapsed. How can I accomplish that?. I have used setInterval or setTimeout functions but it seems that they are not part of JINT since it is based on ECMASCRIPT and this functions are not native.
Can someone tell me how I can do this?.
Thanks!!
Neither
setInterval
andsetTimeout
are supported by Jint because they are part of the Window API in browsers. with Jint, instead of browser, we have access to CLR, and to be honest it's much more versatile.First step is to implement our Timer in CLR side, Here is an extremely simple Timer wrapper for built-int
System.Threading.Timer
class:Next step is to bind out
JsTimer
to Jint engine:Here is an usage example: