0

I have captured a key-combination-press event on my Silverlight Page. Now in the event handler i want to display a prompt box which takes user input and stores into a string variable. I put in this code :

string input = System.Windows.Browser.HtmlPage.Window.Invoke("prompt", new string[] { "QUICK SEARCH", "ENTER YOUR SEARCH ITEM.." }) as string;

But when i run it, It shows me a run time error of AccessViolation error was unhandled saying:"Attempted to read or write protected memory. This is often an indication that other memory is corrupt." any Solutions ??

1 Answers1

0

With lot of searching I found out that Silverlight applcation is a Single Thread activity. And with the above statement I was trying to invoke another thread. I had to use the Dispatcher to sort this problem out. this is how the code goes ..

this.Dispatcher.BeginInvoke(() => javaScriptpopup(sender1, e1));

and then in the javaScriptPopup, I called my string input = System.Windows.Browser.HtmlPage.Window.Invoke("prompt", new string[] { "QUICK SEARCH", "ENTER YOUR SEARCH ITEM.." }) as string; statement.

here sender1 and e1 are the Object and Keyeventargs type!!