C# call an anonymous function

Issue #16 resolved
Luiz Claudio Garcia
created an issue

Hi!

I have defined a JS function calling a C# method through the WebBrowser.AddGlobalJSFunction. I would like to pass JS function as a callback. Something like:

WebBrowser.AddGlobalJSFunction("startEnrollment").Execute += startEnrollment;
public void startEnrollment(object sender, CfrV8HandlerExecuteEventArgs e)
{
     e.Arguments[0].ExecuteFunction;
}

and, in the javascript:

startEnrollment(function(){
   alert('worked from callback');
})

Is there a way to do it?

Best Regards

Comments (3)

  1. wborgsm
    • marked as bug

    Just confirmed the issue. Furthermore, while analyzing the issue I found a deadlock in the interprocess communication with the render process. Maybe fixing that is going to fix this issue as well.

  2. wborgsm

    This should work now. If was not the deadlock but two other bugs prevented correct handling of function call arguments and return values. The deadlock just had the UI freeze once the render process crashed due to the other bugs.

    I added some test code for your use case, see commit 0370486.

    Thanks a lot for your feedback.

  3. Log in to comment