c# - is window.external synchronous or not -
i have discovered window.external
object allows call c# function in winform program hosting ie-like browser.
i red doc on msdn , threads on stackoverflow didn't found if calls synchronous or not, and, customable ?
the thing have founded in msdn doc doesn't speak subject =/
these calls naturally synchronous, makes sense process them asynchronously, avoid otherwise possible reentrancy javascript code. use synchronizationcontext.post that.
e.g. call window.external.testmethod()
javascript. on .net side may this:
this.webbrowser.objectforscripting = new objectforscripting(this.webbrowser); // ... [comvisible(true), classinterface(classinterfacetype.none)] public class objectforscripting { webbrowser _browser; synchronizationcontext _context = synchronizationcontext.current; public objectforscripting(webbrowser browser) { _browser = browser; } public void testmethod() { _context.post(_ => { _browser.document.invokescript("alert", new object[] { "process call javascript asynchronosuly." }); }, null); } }
Comments
Post a Comment