Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

execute code from different threads #3

Closed
SimonCropp opened this issue Feb 16, 2014 · 6 comments
Closed

execute code from different threads #3

SimonCropp opened this issue Feb 16, 2014 · 6 comments

Comments

@SimonCropp
Copy link

Any ideas on this one?

var engine = new MsieJsEngine(JsEngineMode.Auto);

//this works
engine.Execute("var foo = 'ddd';");

//this doesnt
var thread = new Thread(() => engine.Execute("var foobar = 'ddd';"));
thread .Start();
Thread.Sleep(10000);
@Taritsyn
Copy link
Owner

Hello, Simon!

You can't do this! Everything should be run in the one thread.
I recommend you to read the article «JsRT: Runtimes».

@SimonCropp
Copy link
Author

thanks. would u take a PR that throws a more useful exception when people attempt this?

@Taritsyn
Copy link
Owner

What a error message you get?

@Taritsyn Taritsyn reopened this Feb 17, 2014
@SimonCropp
Copy link
Author

System.Runtime.InteropServices.COMException was unhandled
  HResult=-2147418113
  Message=Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
  Source=MsieJavaScriptEngine
  ErrorCode=-2147418113
  StackTrace:
       at MsieJavaScriptEngine.ActiveScript.IActiveScriptParse64.ParseScriptText(String code, String itemName, Object context, String delimiter, IntPtr pSourceContextCookie, UInt32 startingLineNumber, ScriptTextFlags flags, Object& result, EXCEPINFO& exceptionInfo)
       at MsieJavaScriptEngine.ActiveScript.ActiveScriptParseWrapper.ParseScriptText(String code, String itemName, Object context, String delimiter, IntPtr sourceContextCookie, UInt32 startingLineNumber, ScriptTextFlags flags)
       at MsieJavaScriptEngine.ActiveScript.ActiveScriptSiteWrapper.ExecuteScriptText(String code, Boolean isExpression)
       at MsieJavaScriptEngine.ActiveScript.ActiveScriptJsEngineBase.Execute(String code)
       at MsieJavaScriptEngine.MsieJsEngine.Execute(String code)

@SimonCropp
Copy link
Author

It would be better to have an exception

You cannot execute this method on a different thread from which it was constructed.

Taritsyn added a commit that referenced this issue Feb 27, 2014
1. Removed following methods: `HasProperty`, `GetPropertyValue`, `SetPropertyValue` and `RemoveProperty`;
2. Fixed bug #3 "execute code from different threads";
3. Now in the `ChakraJsRt` mode is available a more detailed information about errors;
4. In ECMAScript 5 Polyfill improved a performance of the `String.prototype.trim` function;
5. JSON2 library was updated to version of February 4, 2014.
@Taritsyn
Copy link
Owner

Hello, Simon!

In MSIE JavaScript Engine version 1.4.0 fixed this error. Now in the ChakraActiveScript and Classic modes method calls is performed on single thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants