Pass a JS function as a "Delegate" to an external method {SOLVED}

Aug 2, 2012 at 6:25 AM
Edited Aug 2, 2012 at 6:27 AM

Does Jint support this? Example: 

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C#
...

public static void CallJSMethod(Delegate d)
{
    ((Action<string>)d)("Hello World");
}
jintInstance.SetFunction(CallJSMethod);
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
JavaScript
...

function PrintLine(line)
{
    Printf(line);
}
CallJSMethod(PrintLine);
May 28, 2013 at 10:19 AM
Is this possible?
I am trying with no positive results.

I Just made some change to make it compiling:
C#
...

delegate void CallJSFunctionDelegate(Delegate d);
public static void CallJSMethod(Delegate d)
{
    ((Action<string>)d)("Hello World");
}
jintInstance.SetFunction("CallJSMethod", new CallJSFunctionDelegate(CallJSMethod));
I always get the error:
Object of type 'Jint.Native.JsFunction' cannot be converted to type 'System.Delegate'.

Do anybody can help?

Thanks in advance
Gianni