<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Geekality &#187; Threading</title>
	<atom:link href="http://www.geekality.net/tag/threading/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.geekality.net</link>
	<description>With a hint of Social Ineptitude</description>
	<lastBuildDate>Sun, 05 Feb 2012 17:53:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Quick way to do cross-thread calls to update form controls</title>
		<link>http://www.geekality.net/2008/12/27/quick-way-to-do-cross-thread-calls-to-update-form-controls/</link>
		<comments>http://www.geekality.net/2008/12/27/quick-way-to-do-cross-thread-calls-to-update-form-controls/#comments</comments>
		<pubDate>Sat, 27 Dec 2008 15:34:18 +0000</pubDate>
		<dc:creator>Torleif</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Threading]]></category>
		<category><![CDATA[WinForms]]></category>

		<guid isPermaLink="false">http://www.geekality.net/?p=64</guid>
		<description><![CDATA[When doing background work you often want to call back to a user interface and let the user know that you are not dead. However, this is can be a bit difficult some times because windows forms can only be &#8230; <a href="http://www.geekality.net/2008/12/27/quick-way-to-do-cross-thread-calls-to-update-form-controls/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When doing background work you often want to call back to a user interface and let the user know that you are not dead. However, this is can be a bit difficult some times because windows forms can only be updated by code running on the same thread as the forms are. So, to get around this you can for example use a method called <code class="codecolorer csharp default"><span class="csharp">Invoke</span></code> on the control or form you need to update.</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">void</span> SomeEventHandler<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> sender, SomeEventArgs e<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// Check if invoke is required</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>InvokeRequired<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// And if it is, call Invoke on the form with a delegate to this same method and return.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Invoke<span style="color: #008000;">&#40;</span><span style="color: #008000;">new</span> Action<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">object</span>, SomeEventArgs<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span>SomeEventHandler<span style="color: #008000;">&#41;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000;">new</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">&#123;</span> sender, e <span style="color: #008000;">&#125;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// Second time around, InvokeRequired will be false and it will skip </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// here where you can update the controls you need to update</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span></div></div>
<p class="wp-flattr-button"></p>]]></content:encoded>
			<wfw:commentRss>http://www.geekality.net/2008/12/27/quick-way-to-do-cross-thread-calls-to-update-form-controls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

