Question about use as a script engine

Oct 17, 2012 at 6:54 PM

Hello, I searched several javascript and find your work really awesome. I have some questions about what it can do. I wants to do the following things in javascript, by loading a user script file:

1. A complex script may need to create thread to do different things, can I create thread and control them (stop / (re)start / dispose) in javascript?

2. A complex script may include some other script-lib, does this kind of script supported?

3. Wants  to use C# List or Array in javascript, can I do it?

4. Pass data from C# to and back ?

That's what I can imagine currently.. I am really newbie of this tipic.



Nov 4, 2012 at 12:34 AM
  1. There is no support for threading in the javascript standard library, so no support in Jurassic either.  You could, however, build a web-workers style system pretty easily, with a separate ScriptEngine per thread.  See this page:
  2. Nope, sorry, no support for including other scripts (from within JavaScript) because again ECMAScript 5 doesn't support it.  But it's easy to use the ScriptEngine to execute as many scripts as you like.
  3. No, I don't support this either, sorry.
  4. There are a few ways to do this.  You can construct javascript objects in C# (Jurassic.Library.ObjectInstance) and pass them to a javascript function (Using CallGlobalFunction or Call on a FunctionInstance).  Then you can read the ObjectInstance that gets returned.  Or you could convert everything to JSON and pass that back and forth.  See this page: