Any way to abort execution?

Mar 7, 2012 at 1:54 PM

Hi,

I'm using Javascript.NET to add scripting support to my application. The Scripts are edited by the end user, so he can enter something like "while(true);" ...

Is there any way to abort script execution? I've tried to kill the thread, but this didn't work.

Thank for any informations :)

 

Greetings,

LittleFox

Mar 8, 2012 at 11:53 AM

Hi,

I've just uploaded a patch to wrap v8::V8::TerminateExecution(). The only problem is, it kills every javascript, but this is better then nothing ;)

Greetings,

LittleFox

Developer
Mar 8, 2012 at 11:14 PM

I've applied your patch.  There is a version of TerminateExecution that takes a thread ID, perhaps that would be more precise.

Mar 9, 2012 at 7:28 AM

Hi,

what kind of thread ID takes it? Managed or unmanaged? The problem is, these aren't the same.

Greetings,

LittleFox

Developer
Mar 18, 2012 at 10:36 PM

I'm not sure, but I notice that the new version of v8 can take a pointer to an Isolate, which we now store in the JavascriptContext.  Make TerminateExecution a non-static member of JavascriptContext, and having it use its Isolate, would probably be the simplest solution.

  Oliver

Mar 27, 2012 at 7:52 AM

Hi,

that sounds good! Will this be in the next version? I don't think this should be a problem.

I think, the static function should stay included for compatibility reasons. It's also good to kill every running javascript.

Greetings,

LittleFox

Developer
Apr 12, 2012 at 3:59 AM
littlefox wrote:

that sounds good! Will this be in the next version? I don't think this should be a problem.

I think, the static function should stay included for compatibility reasons. It's also good to kill every running javascript.

I have committed a change so that TerminateExecution is no longer a static function.  It terminates any thread running on that JavascriptContext, via its v8 Isolate.  I have not preserved the static version because supplying no Isolate does not terminate all threads, it only terminates threads in the default Isolate (of which there are probably none, since we create Isolates explicitly).  See http://bespin.cz/~ondras/html/classv8_1_1V8.html#a81a47f6709c7d376a448d6315398aeb8

Apr 24, 2012 at 10:31 AM

Hi,

sorry for the delay - I was working at another part from out project.

I've updated the library and it seems to work - thank you for that :)

Greetings,

LittleFox