<?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>Got # ?</title>
	<atom:link href="http://gotsharp.be/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://gotsharp.be</link>
	<description>Got Sharp?</description>
	<lastBuildDate>Sun, 21 Feb 2010 20:03:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>GotSharp.Extensions</title>
		<link>http://gotsharp.be/?p=47</link>
		<comments>http://gotsharp.be/?p=47#comments</comments>
		<pubDate>Sun, 21 Feb 2010 20:03:00 +0000</pubDate>
		<dc:creator>Wesley</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://gotsharp.be/?p=47</guid>
		<description><![CDATA[GotSharp is proudly presenting: GotSharp.Extensions!
GotSharp.Extensions is a .NET Class Library containing extension methods and utility classes. Right now, it contains only some extension methods for the System.String and System.IO.Stream classes, and the utility class Range (with implementations Int32Range and DateTimeRange). We will keep updating it however with new functionality.  Feel free to give comment [...]]]></description>
			<content:encoded><![CDATA[<p>GotSharp is proudly presenting: GotSharp.Extensions!</p>
<p>GotSharp.Extensions is a .NET Class Library containing extension methods and utility classes. Right now, it contains only some extension methods for the System.String and System.IO.Stream classes, and the utility class Range (with implementations Int32Range and DateTimeRange). We will keep updating it however with new functionality.  Feel free to give comment or feature requests, but please do so on the project page, <a href="http://gotsharpextensions.codeplex.com">hosted at CodePlex</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://gotsharp.be/?feed=rss2&amp;p=47</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Prepared Statements and the &#8220;Parameter X has no default value&#8221; error</title>
		<link>http://gotsharp.be/?p=40</link>
		<comments>http://gotsharp.be/?p=40#comments</comments>
		<pubDate>Wed, 27 Jan 2010 10:40:48 +0000</pubDate>
		<dc:creator>Wesley</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[VB]]></category>
		<category><![CDATA[ado.net]]></category>
		<category><![CDATA[DbCommand]]></category>
		<category><![CDATA[nullable]]></category>
		<category><![CDATA[OleDbCommand]]></category>
		<category><![CDATA[prepared statement]]></category>

		<guid isPermaLink="false">http://gotsharp.be/?p=40</guid>
		<description><![CDATA[When I stumbled upon this error &#8220;parameter @columnName has no default value&#8221;, first thing I tried was Google, of course.  When googling, I found lots of answers for this problem, but they all resulted in the following solutions:



Parameter name is different in the query and when declaring the parameter (wrong columnName, or wrong parameter assigned [...]]]></description>
			<content:encoded><![CDATA[<p>When I stumbled upon this error &#8220;parameter @columnName has no default value&#8221;, first thing I tried was Google, of course.  When googling, I found lots of answers for this problem, but they all resulted in the following solutions:
</p>
<ul>
<li>
<p>Parameter name is different in the query and when declaring the parameter (wrong columnName, or wrong parameter assigned &#8211; the copy/paste error)</p>
</li>
<li>
<p>The parameters are not in the right order (especially true when querying Microsoft Access databases)</p>
</li>
</ul>
<p>&nbsp;<br />
Because you&#8217;re reading this, you can assume by now that I hadn&#8217;t found a solution for my problem.  Well, that&#8217;s not entirely true, but I still needed another solution to completely solve my problem.</p>
<p><span id="more-40"></span></p>
<p>First issue: the order of parameters was incorrect. But when you google around for query expression in Access, you&#8217;ll see two ways for defining parameters: using question marks, or a parameter name.  I was using parameter names, and expected that the DbCommand object (actually a OleDbCommand object) would map the parameters correctly.</p>
<p>It appears that I was wrong.</p>
<p>Whether you use names or question marks doesn&#8217;t matter when the command object is mapping the values, it just fills up the parameters in the query one by one.</p>
<p>Second issue: I&#8217;m using Nullable&#8217;s in my model class.  For those who don&#8217;t know what Nullable is: ever had a DateTime in a model class and a &#8220;datetime&#8221; field in a database table with NULL as its value?  What value did you give your DateTime field? DateTime.MinValue? Or did you keep track whether the value was set or not with a boolean?<br />
Nullable was added to the .NET Framework 2.0 for this problem.  You can use it to wrap basic data types and structures, like int (Integer), decimal (Decimal), DateTime, &#8230;</p>
<p>In C#:</p>
<p>Nullable&lt;<span style="color: #0000ff;"><strong>int</strong></span>&gt; nValueOrNull;<br />
OR<br />
<span style="color: #0000ff;"><strong>int<span style="color: #000000;"><span style="font-weight: normal;">?</span></span></strong></span> nValueOrNull;</p>
<p>In VB.Net:</p>
<p><strong><span style="color: #0000ff;">Dim</span></strong> nValueOrNothing <strong><span style="color: #0000ff;">As</span></strong> Nullable(<span style="color: #0000ff;"><strong>Of Integer</strong></span>)<br />
OR<br />
<span style="color: #0000ff;"><strong>Dim</strong></span> nValueOrNothing<span style="color: #0000ff;"><strong><span style="color: #0000ff;"><span style="font-weight: normal;"><span style="color: #000000;">?</span></span></span> As Integer</strong></span><br />
OR<br />
<span style="color: #0000ff;"><strong>Dim</strong></span> nValueOrNothing <span style="color: #0000ff;"><strong>As Integer<span style="color: #000000;"><span style="font-weight: normal;">?</span></span></strong></span></p>
<p>Note that the last two ways of defining a Nullable in VB.Net are only available from .NET Framework 3.5 and higher. More information: <a href="http://msdn.microsoft.com/en-us/library/ms235245.aspx">http://msdn.microsoft.com/en-us/library/ms235245.aspx</a></p>
<p>Now, when I assign a field (which is a Nullable&lt;int&gt;) to a parameter object, and that field contains no value (I deliberately didn&#8217;t say: that field is null), I expected that the command or even the parameter itself would translate that to NULL in the database, especially because the IsNullable property of the parameter was set to True.  Of course, I was wrong about my assumptions.  After trying some things, eventually I tried passing DBNull.Value when my field contained no value: that did the trick.</p>
<p>So, in short: null (or Nothing) is NOT the same as DBNull.Value when assigning values to query parameters.  Nullable can help you matching a model class to a database table, but doesn&#8217;t help when translating DBNull from a query result or to a query parameter.</p>
]]></content:encoded>
			<wfw:commentRss>http://gotsharp.be/?feed=rss2&amp;p=40</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows 7 and its System process hogging up the CPU</title>
		<link>http://gotsharp.be/?p=37</link>
		<comments>http://gotsharp.be/?p=37#comments</comments>
		<pubDate>Thu, 14 Jan 2010 11:00:18 +0000</pubDate>
		<dc:creator>Wesley</dc:creator>
				<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[cpu]]></category>
		<category><![CDATA[kernel]]></category>
		<category><![CDATA[lmhosts]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[system]]></category>
		<category><![CDATA[windows 7]]></category>

		<guid isPermaLink="false">http://gotsharp.be/?p=37</guid>
		<description><![CDATA[If you&#8217;re running Windows 7 and find that from time to time, you PC slows down for 5-10 seconds, try to monitor the System process (NT Kernel &#38; System, or ntoskrnl.exe): chances are that this process is hogging the CPU.  If it is, take a look at your network adapter(s) properties and check if LMHOSTS [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re running Windows 7 and find that from time to time, you PC slows down for 5-10 seconds, try to monitor the System process (NT Kernel &amp; System, or ntoskrnl.exe): chances are that this process is hogging the CPU.  If it is, take a look at your network adapter(s) properties and check if LMHOSTS lookup is enabled.</p>
<p>Apparently, there is a bug in the kernel when looking up the LMHOSTS table, causing the CPU to enter a semi-infinite loop. Semi-infinite, because the thread times out after a few seconds.</p>
<p>For more information, look <a href="http://forums.pcper.com/showthread.php?t=466616" target="_blank">here</a> (original forum post) and the <a href="http://support.microsoft.com/kb/955860" target="_blank">KB article</a> at Microsoft (more specifically, workaround #2).  Although the KB article is originally for Windows Server 2003 platforms, it also applies to Windows 7, just don&#8217;t try to install the hotfix on you Windows 7 machine!</p>
]]></content:encoded>
			<wfw:commentRss>http://gotsharp.be/?feed=rss2&amp;p=37</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FoxPro, Memo fields and updating them</title>
		<link>http://gotsharp.be/?p=27</link>
		<comments>http://gotsharp.be/?p=27#comments</comments>
		<pubDate>Thu, 12 Mar 2009 09:36:27 +0000</pubDate>
		<dc:creator>Wesley</dc:creator>
				<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[VB]]></category>
		<category><![CDATA[adodb]]></category>
		<category><![CDATA[appendchunk]]></category>
		<category><![CDATA[command]]></category>
		<category><![CDATA[foxpro]]></category>
		<category><![CDATA[memo]]></category>
		<category><![CDATA[odbc]]></category>

		<guid isPermaLink="false">http://www.gotsharp.be/?p=27</guid>
		<description><![CDATA[When you are (still) using ODBC or ADODB to update memo fields in a FoxPro table, you might run into the problem that all of your rows are updated instead of just the one when using AppendChunk.  This is probably caused by the fact that memo&#8217;s are stored in a separate FPT file, organized in [...]]]></description>
			<content:encoded><![CDATA[<p>When you are (still) using ODBC or ADODB to update memo fields in a FoxPro table, you might run into the problem that all of your rows are updated instead of just the one when using AppendChunk.  This is probably caused by the fact that memo&#8217;s are stored in a separate FPT file, organized in blocks (or chunks, if you will) of text.  The memo field in the table holds a pointer to the first block in the FPT file.</p>
<p>The FoxPro ODBC driver seems to have problems setting the pointer when you set the memo of a row using a RecordSet.  If there are other rows after the current one with empty memo fields, the driver sets the pointer in those rows as well. Examine the following code:</p>
<p><code>rs.Open ...<br />
<span style="color: #0000ff;"> While Len</span>(sMemoData) &gt; 254<br />
    rs.Fields("Memo").AppendChunk <span style="color: #0000ff;">Left</span>(sMemoData, 254)<br />
    sMemoData = <span style="color: #0000ff;">Right</span>(sMemoData, <span style="color: #0000ff;">Len</span>(sMemoData) - 254)<br />
<span style="color: #0000ff;"> Wend</span></code></p>
<p><code> </code></p>
<p><code><span style="color: #0000ff;">If Len</span>(sMemoData) &gt; 0 <span style="color: #0000ff;">Then </span>rs.Fields("Memo").AppendChunk sMemoData<br />
rs.Update </code></p>
<p>To avoid this from happening, you can use a ADO Command object and use parameters instead.  Make sure you set the correct size in the parameter!</p>
<p><code>cmdAdo.CommandText = "UPDATE table SET Memo = ? WHERE Field = 'a value'"<br />
<span style="color: #0000ff;"> Set </span>pMemo = cmdAdo.CreateParameter("Memo", ...)<br />
pMemo.Size = <span style="color: #0000ff;">Len</span>(sMemoData)<br />
pMemo.Value = ""</code></p>
<p><code><span style="color: #0000ff;">While Len</span>(sMemoData) &gt; 254<br />
    pMemo.AppendChunk <span style="color: #0000ff;">Left</span>(sMemoData, 254)<br />
    sMemoData = <span style="color: #0000ff;">Right</span>(sMemoData, <span style="color: #0000ff;">Len</span>(sMemoData) - 254)<br />
<span style="color: #0000ff;"> Wend</span></p>
<p><span style="color: #0000ff;">If Len</span>(sMemoData) &gt; 0 <span style="color: #0000ff;">Then </span>pMemo.AppendChunk sMemoData</p>
<p>cmdAdo.Parameters.Append pMemo</p>
<p></code></p>
<p><code>cmdAdo.Execute </code></p>
]]></content:encoded>
			<wfw:commentRss>http://gotsharp.be/?feed=rss2&amp;p=27</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Log4Net, custom PatternLayout</title>
		<link>http://gotsharp.be/?p=24</link>
		<comments>http://gotsharp.be/?p=24#comments</comments>
		<pubDate>Wed, 25 Feb 2009 10:02:48 +0000</pubDate>
		<dc:creator>Wesley</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[Tips & Tricks]]></category>

		<guid isPermaLink="false">http://www.gotsharp.be/?p=24</guid>
		<description><![CDATA[I was looking for a way to add my own parsers to the PatternLayout class, and found following solution:
public class CustomPatternLayout : PatternLayout {
        protected override PatternParser CreatePatternParser(string pattern) {
            PatternParser parser = base.CreatePatternParser(pattern);

    [...]]]></description>
			<content:encoded><![CDATA[<p>I was looking for a way to add my own parsers to the PatternLayout class, and found following solution:</p>
<pre><strong><span style="color: #0000ff;">public class</span></strong> CustomPatternLayout : PatternLayout {
        <strong><span style="color: #0000ff;">protected override</span></strong> PatternParser CreatePatternParser(<strong><span style="color: #0000ff;">string</span></strong> pattern) {
            PatternParser parser = <strong><span style="color: #0000ff;">base</span></strong>.CreatePatternParser(pattern);

            <span style="color: #009900;">//usage: %CustomField or %cf (case-sensitive)</span>
            parser.PatternConverters["CustomField"] =  <strong><span style="color: #0000ff;">typeof</span></strong>(CustomPatternConverter);
            parser.PatternConverters["cf"] =  <strong><span style="color: #0000ff;">typeof</span></strong>(CustomPatternConverter);

            <strong><span style="color: #0000ff;">return</span></strong> parser;
        }
    }
</pre>
]]></content:encoded>
			<wfw:commentRss>http://gotsharp.be/?feed=rss2&amp;p=24</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Select All Text In A MaskedTextBox On Enter</title>
		<link>http://gotsharp.be/?p=19</link>
		<comments>http://gotsharp.be/?p=19#comments</comments>
		<pubDate>Thu, 25 Sep 2008 09:02:02 +0000</pubDate>
		<dc:creator>Wesley</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[VB]]></category>

		<guid isPermaLink="false">http://www.gotsharp.be/?p=19</guid>
		<description><![CDATA[I encountered something weird yesterday evening.  In a MaskedTextBox, I wanted to select the entire text when a user enters the box, using the SelectAll method in an Enter event handler.  It didn&#8217;t work&#8230;
Fortunately, we have Google! After a quick search I found someone with the same problem and a solution.  By simply invoking (and [...]]]></description>
			<content:encoded><![CDATA[<p>I encountered something weird yesterday evening.  In a MaskedTextBox, I wanted to select the entire text when a user enters the box, using the SelectAll method in an Enter event handler.  It didn&#8217;t work&#8230;</p>
<p>Fortunately, we have Google! After a quick search I found someone with the same problem and a solution.  By simply invoking (and postponing) the SelectAll call, it will work.  The MaskedTextBox has its own selection thing going on in it&#8217;s Focus event handler, that&#8217;s why just doing SelectAll doesn&#8217;t work.</p>
<p>Here&#8217;s what you must do: (C#)</p>
<pre><strong><span style="color: #0000ff;">private void</span></strong> txtMaskedTextBox_Enter(<strong><span style="color: #0000ff;">object </span></strong>sender, EventArgs e) {
    <strong><span style="color: #0000ff;">this</span></strong>.BeginInvoke( (MethodInvoker) <strong><span style="color: #0000ff;">delegate</span></strong>() {
        txtMaskedTextBox.SelectAll();
    } );
} </pre>
<p>You can&#8217;t use anonymous delegates in VB.Net 2005 (don&#8217;t know if you can in VS 2008), so you must create a new delegate and method.  But you can make it more generic at the same time, because I&#8217;ve also seen normal TextBoxes behaving like this from time to time.</p>
<pre><strong><span style="color: #0000ff;">Private Delegate Sub</span></strong> SelectAllInvoker(txtBox <span style="color: #0000ff;"><strong>As</strong></span> TextBoxBase)

<strong><span style="color: #0000ff;">Private Sub</span></strong> SelectAll(<strong><span style="color: #0000ff;">ByVal</span></strong> txtBox <span style="color: #0000ff;"><strong>As </strong></span>TextBoxBase)
    txtBox.SelectAll()
<strong><span style="color: #0000ff;">End Sub</span></strong>

<strong><span style="color: #0000ff;">Private Sub</span></strong> txtMaskedTextBox_Enter(<span style="color: #0000ff;"><strong>ByVal </strong></span>sender <span style="color: #0000ff;"><strong>As Object</strong></span>, <span style="color: #0000ff;"><strong>ByVal </strong></span>e <span style="color: #0000ff;"><strong>As </strong></span>EventArgs)
    <strong><span style="color: #0000ff;">Me</span></strong>.BeginInvoke(<strong><span style="color: #0000ff;">New </span></strong>SelectAllInvoker(<strong><span style="color: #0000ff;">AddressOf </span></strong>SelectAll), _
                   <strong><span style="color: #0000ff;">DirectCast</span></strong>(sender, TextBoxBase))
<strong><span style="color: #0000ff;">End Sub</span></strong> </pre>
]]></content:encoded>
			<wfw:commentRss>http://gotsharp.be/?feed=rss2&amp;p=19</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>MultiLayout v1.1.3 is here!</title>
		<link>http://gotsharp.be/?p=13</link>
		<comments>http://gotsharp.be/?p=13#comments</comments>
		<pubDate>Wed, 10 Sep 2008 16:28:12 +0000</pubDate>
		<dc:creator>Wesley</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Tips & Tricks]]></category>

		<guid isPermaLink="false">http://www.gotsharp.be/?p=13</guid>
		<description><![CDATA[MultiLayout is a little .NET utility that draws every supported resolution as an overlay on your screen.  This allows you to quickly see which resolutions support your forms or websites (or better, the other way around).
Visit this page for more information, the download link and future updates.
]]></description>
			<content:encoded><![CDATA[<p>MultiLayout is a little .NET utility that draws every supported resolution as an overlay on your screen.  This allows you to quickly see which resolutions support your forms or websites (or better, the other way around).</p>
<p>Visit <a href="http://www.gotsharp.be/MultiLayout">this page</a> for more information, the download link and future updates.</p>
]]></content:encoded>
			<wfw:commentRss>http://gotsharp.be/?feed=rss2&amp;p=13</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>We&#8217;re looking for contributors!</title>
		<link>http://gotsharp.be/?p=7</link>
		<comments>http://gotsharp.be/?p=7#comments</comments>
		<pubDate>Fri, 09 May 2008 10:15:15 +0000</pubDate>
		<dc:creator>Wesley</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.gotsharp.be/?p=7</guid>
		<description><![CDATA[Are you proficient with .NET?  Care to share your knowledge with other developers?  Then join Got #!
Just register yourself on this website, and send an e-mail to contribute [at] gotsharp [dot] be containing the username you used to register yourself, and some details about yourself (especially about your .NET abilities).  We will get back to [...]]]></description>
			<content:encoded><![CDATA[<p>Are you proficient with .NET?  Care to share your knowledge with other developers?  Then join Got #!</p>
<p>Just <a href="http://www.gotsharp.be/wp-login.php?action=register">register yourself</a> on this website, and send an e-mail to contribute [at] gotsharp [dot] be containing the username you used to register yourself, and some details about yourself (especially about your .NET abilities).  We will get back to you as soon as possible to inform whether you are accepted as a contributor or not.</p>
]]></content:encoded>
			<wfw:commentRss>http://gotsharp.be/?feed=rss2&amp;p=7</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Multithreading does not have to be hard</title>
		<link>http://gotsharp.be/?p=4</link>
		<comments>http://gotsharp.be/?p=4#comments</comments>
		<pubDate>Wed, 16 Apr 2008 21:12:58 +0000</pubDate>
		<dc:creator>Wesley</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[VB]]></category>

		<guid isPermaLink="false">http://www.gotsharp.be/?p=4</guid>
		<description><![CDATA[When you write an application that takes some time to complete a task, it might become unresponsive to the user.  Ever seen an application turn all white when clicking it?
The answer to solve this is multithreading.  But writing a multithreaded application can be quite difficult.  If you rush into coding, you quickly [...]]]></description>
			<content:encoded><![CDATA[<p>When you write an application that takes some time to complete a task, it might become unresponsive to the user.  Ever seen an application turn all white when clicking it?</p>
<p>The answer to solve this is multithreading.  But writing a multithreaded application can be quite difficult.  If you rush into coding, you quickly forget about locking shared data, resulting in possible deadlock situations.  And even when you have a relatively simple algorithm that you want to run in a second thread, like copying lots of files or preparing a Crystal Report document to print, it can be quite troublesome to reach that goal.  Especially if you want to give feedback while executing the thread (like a ProgressBar that gradually fills up), or support cancellation.</p>
<p>In .Net 2.0, it doesn&#8217;t need to be so difficult.  You can easily make most simple tasks (and perhaps even some of the more complex ones) multithreaded by using the BackgroundWorker control.</p>
<p><span id="more-4"></span>The BackgroundWorker control, when you add it to a Form, sits in the Component Tray (the gray area that holds all controls that are never visible on a Form). At Design Time, you only need to worry about the WorkerReportsProgress and WorkerSupportsCancellation properties.  If your BackgroundWorker instance is going to report progress in the task(s) it will perform, you should set WorkerReportsProgress to true.  If you want to enable the user to cancel the task(s), you should set WorkerSupportsCancellation to true.</p>
<p>To implement the BackgroundWorker, you need to use the DoWork event.  When the application requests that the BackgroundWorker starts its thread, the BackgroundWorker fires the DoWork event.<br />
Two other events to look at are ProgressChanged and RunWorkerCompleted.  If you report a progress update, the ProgressChanged event is fired so you can update a ProgressBar, or maybe a Label that holds information about what the application is doing.  The RunWorkerCompleted is fired when the BackgroundWorker ends its thread (usually after exiting the DoWork event handler).  You can use that event to restore your UI to a specific state, like re-enabling buttons that were disabled while running the task(s).<br />
Before we begin with our example, some important notes: in the DoWork event, you can not access the UI of the Form.  This is typically the case when you&#8217;re in another thread (the UI runs in its own thread): the Framework disallows you to &#8220;jump&#8221; to the UI thread when your not currently there.<br />
That&#8217;s the reason why there is a separate ProgressChanged event.  When you report progress updates, the BackgroundWorker <em><a href="http://msdn2.microsoft.com/en-us/library/system.windows.forms.control.invoke.aspx" target="_blank">invokes</a></em> the ProgressChanged event on the UI&#8217;s thread (or in other words, the BackgroundWorker makes sure that the Form controls are accessable inside the ProgressChanged event handler).</p>
<h3>Example</h3>
<p>Let&#8217;s say that you want to copy a folder that contains approximately 1 GiB of data.  This might take a while, and you want to inform the user of the progress and enable him to cancel the process.<br />
Typically, you would show a modal status Form, to keep the user from pressing buttons in another Form (think of the copy file dialog that appears when copying files in Explorer).</p>
<p>Download example solution (VB.NET project): <a href="http://www.gotsharp.be/wp-content/uploads/2008/04/backgroundworkersample.zip">BackgroundWorker Sample</a><a href="http://www.gotsharp.be/wp-content/uploads/2008/04/backgroundworker.vb"></a><br />
This zip file contains the solution and VB.NET project.  Created in Visual Studio 2005, but you should be able to open it with Visual Studio 2008 as well, either bought or Express editions.</p>
]]></content:encoded>
			<wfw:commentRss>http://gotsharp.be/?feed=rss2&amp;p=4</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Welcome to Got #?</title>
		<link>http://gotsharp.be/?p=3</link>
		<comments>http://gotsharp.be/?p=3#comments</comments>
		<pubDate>Mon, 07 Apr 2008 08:46:37 +0000</pubDate>
		<dc:creator>Wesley</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.gotsharp.be/?p=3</guid>
		<description><![CDATA[Got #? (pronounced got sharp) is my blog about IT related things.  Expect information about the .Net Framework, JavaScript, Visual Studio, problems, solutions, &#8230;  At the moment, I&#8217;m not doing any Java at all, so you won&#8217;t find much about it here.  That might change however, you never know what you&#8217;ll end [...]]]></description>
			<content:encoded><![CDATA[<p>Got #? (pronounced <em>got sharp</em>) is my blog about IT related things.  Expect information about the .Net Framework, JavaScript, Visual Studio, problems, solutions, &#8230;  At the moment, I&#8217;m not doing any Java at all, so you won&#8217;t find much about it here.  That might change however, you never know what you&#8217;ll end up doing in a few years.</p>
<p>I am Wesley Cabus, a software architect at Quality Software bvba in Belgium.  Currently, I&#8217;m mostly active in JavaScript inside CaseWare Working Papers.  I&#8217;m also experimenting with the .Net platform in my time off, trying out some challenging stuff (i.e. threading, reflection) and the latest new technologies (WPF, LINQ, &#8230;).</p>
]]></content:encoded>
			<wfw:commentRss>http://gotsharp.be/?feed=rss2&amp;p=3</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
