When running in a non-UI thread in Silverlight, you can dispatch back to the UI 
thread for UI interaction. Every UIElement has a "Dispatcher" property, so you 
just need to grab that and call BeginInvoke, passing a delegate.

// In some background thread
Application.Current.RootVisual.Dispatcher.BeginInvoke(delegate() {
  HtmlPage.Document.GetElementById("foo").SetProperty("innerHTML", "hi!")
});

From: users-boun...@lists.ironpython.com 
[mailto:users-boun...@lists.ironpython.com] On Behalf Of Kristian Jaksch
Sent: Friday, March 20, 2009 6:00 AM
To: Discussion of IronPython
Subject: Re: [IronPython] Best way to stop script execution?

What about if we need access to the HTML DOM (It's a silverlight application) 
from that thread? During execution of scripts there might be printouts to the 
DOM. But how can we do that without illegal cross-threading?

2009/3/19 Kristian Jaksch 
<kristian.jak...@gmail.com<mailto:kristian.jak...@gmail.com>>
Thanks for the reply.

No, we haven't placed the script execution in their own thread. I guess the 
best way must be just to place the exec command in that thread. I'll check out 
Thread.Abort.

2009/3/19 Michael Foord 
<fuzzy...@voidspace.org.uk<mailto:fuzzy...@voidspace.org.uk>>

Kristian wrote:
We let users execute scripts in our app using the exec command. We
want to provide a stop button to stop script execution but how is the
best way to do that? Can a background worker be used for that?



Are the user scripts already running in a thread of their own? If they are you 
can abort the thread (with all the consequences that brings) using Thread.Abort.

Michael

Thanks for help!
_______________________________________________
Users mailing list
Users@lists.ironpython.com<mailto:Users@lists.ironpython.com>
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog



_______________________________________________
Users mailing list
Users@lists.ironpython.com<mailto:Users@lists.ironpython.com>
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


_______________________________________________
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to