Jurassic does not have an built-in way to limit the execution time of a script. Because Jurassic compiles JavaScript methods into IL code, there is no easy way to provide a timeout functionality without affecting performance.
However, it is possible to use Thread.Abort()
to raise a ThreadAbortException
in the thread that executes the script. One possibility is to run ScriptEngine.Execute()
in a new thread and call thread.Abort()
in the current thread if the new thread does not complete after a specific time.
Source
If you read through the documentation, they do have suggestions for how to do this but it is a bit lengthy and involved.