Nov 30, 2010 at 9:41 PM


Great work!

I have a function defined in JavaScript that I would like to pass into my .NET method. For example:

service.callMeBackWhenDone("SELECT * FROM TABLE", function(results
     // Do something with results

class Service
   void callMeBackWhenDone(string query, object callback)
       // Do the query async and call callback when done.

What should my .NET type for the callback arg of the method be? I tried 'object' but got a null. Tried Delegate but got an exception.

Many thanks


Feb 24, 2011 at 7:59 AM

Do you found how this can be done?  I'm facing exact same problem...

Feb 25, 2011 at 6:15 PM
Edited Feb 25, 2011 at 6:15 PM

This functionality is currently not supported. Re-entrant processes in the Javascript context is likely to cause important stability issues (running JavascriptContext.Run( ) from .NET code called by Javascript code)

Ansynchronous calls are also unsupported by Javascript.NET internally. However mecanisms external to Javascript.NET can be implemented to support them. A callback mecanism could be implemented by making a second call to JavascriptContext.Run( ), using a statement provided by the Javascript code. Keep in mind that callbacks may only be called once the JavascriptContext.Run( ) call that initiated the async process has returned, since the V8 engine does not support multithreading at all.