SilverlightShow: Tip: How to invoke method in the UI thread? Comments
http://www.silverlightshow.net/
Silverlight articles, Silverlight tutorials, Silverlight videos, Silverlight samples
SilverlightShow.net
http://www.rssboard.org/rss-specification
Argotic Syndication Framework 2008.0.2.0, http://www.codeplex.com/Argotic
en-US
estoychev@completit.com (Emil Stoychev)
-
RE: How to invoke method in the UI thread?
<p>10x <span id="ctl00_ContentPlaceHolderContent_itemComments_dlstComments_ctl00_lblCommentAuthor">aquaseal!</span></p>
<p><span>This is also very useful method!</span></p>
http://www.silverlightshow.net/items/How-to-invoke-method-in-the-UI-thread.aspx#comment339
iiordanov
http://www.silverlightshow.net/items/How-to-invoke-method-in-the-UI-thread.aspx
Mon, 01 Sep 2008 04:27:04 GMT
-
RE: How to invoke method in the UI thread?
<p>Also, a hidden method (hidden from intellisense) is <a href="http://msdn.microsoft.com/en-us/library/system.windows.threading.dispatcher.checkaccess.aspx">CheckAccess()</a> which is very useful to see if the thread is on the render thread and if not invoke that same method again. Here's a quick example:<span style="text-decoration: underline;"><br />
</span></p>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"><span style="color: rgb(0, 0, 255);">private</span> <span style="color: rgb(0, 0, 255);">void</span> OtherThreadMethod()
</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);">
{
</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);">
if(!<span style="color: rgb(0, 0, 255);">this</span>.Dispatcher.CheckAccess())
</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);">
{
</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"><span style="color: rgb(0, 0, 255);"> this</span>.Dispatcher.BeginInvoke( OtherThreadMethod );
</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);">
}
}
</pre>
<p> </p>
http://www.silverlightshow.net/items/How-to-invoke-method-in-the-UI-thread.aspx#comment337
aquaseal
http://www.silverlightshow.net/items/How-to-invoke-method-in-the-UI-thread.aspx
Fri, 29 Aug 2008 14:17:10 GMT