Do calls made from Silverlight to Javascript through HtmlPage.Window.Invoke() return immediately or are they synchronous?
Do calls made from Silverlight to Javascript through HtmlPage.Window.Invoke() return immediately or are they
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Invoke is synchronous from the point of view of your Silverlight code – control will not return to the Silverlight code until the JavaScript code returns. It’s easy to see this must be the case because
Invokereturns a value which you can use immediately.You can even call back into Silverlight from JavaScript via a
ScriptableMemberin a nested fashion during the call (though I wouldn’t recommend ping-ponging back and forth like that!).This synchronous calling can be problematic, not just for responsiveness – some nasty reentrancy issues can arise. I’d recommend either keeping JavaScript code you call from Silverlight as small as possible, or failing that set a timer to run some code, so that control will return immediately to Silverlight, and the code will execute from the JavaScript event loop instead (giving you effectively an asynchronous call).