<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>Elegant Code</title>
	
	<link>http://elegantcode.com</link>
	<description />
	<pubDate>Sun, 05 Jul 2009 19:39:21 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/ElegantCode" type="application/rss+xml" /><item>
		<title>MSpec – Take 2</title>
		<link>http://elegantcode.com/2009/07/05/mspec-take-2/</link>
		<comments>http://elegantcode.com/2009/07/05/mspec-take-2/#comments</comments>
		<pubDate>Sun, 05 Jul 2009 19:38:25 +0000</pubDate>
		<dc:creator>cbilson</dc:creator>
		
		<category><![CDATA[Testing]]></category>

		<category><![CDATA[Tools and Utilities]]></category>

		<category><![CDATA[Unit Testing]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/07/05/mspec-take-2/</guid>
		<description><![CDATA[About a year ago, I remember first hearing about Machine.Specifications (github) and trying it out for something I was developing. I liked it right away, especially the way it cut away a lot of the noise involved with writing tests/specifications.
I never really ended up using MSpec on things at work. There were lots of lame [...]]]></description>
			<content:encoded><![CDATA[<p>About a year ago, <a href="http://codebetter.com/blogs/gregyoung/archive/2008/07/19/bellware-driven-design.aspx">I remember first hearing about</a> <a href="http://codebetter.com/blogs/aaron.jensen/archive/2008/05/08/introducing-machine-specifications-or-mspec-for-short.aspx">Machine.Specifications</a> <a href="http://github.com/machine/machine.specifications/tree/master">(github)</a> and trying it out for something I was developing. I liked it right away, especially the way it cut away a lot of the noise involved with writing tests/specifications.</p>
<p>I never really ended up using MSpec on things at work. There were lots of lame reasons:</p>
<ul>
<li>We were using MbUnit and MSpec worked with NUnit (like I really care, seriously) </li>
<li>We already had lots of existing tests and didn&#8217;t want the disjointed feeling of having two ways to do things </li>
<li>I was already struggling at work getting people to adopt the new things I had <em>already</em> introduced into our environment. </li>
</ul>
<p>I took what I could out of MSpec and the other Spec Driven Development stuff I got from the community and kind of rolled my own style of doing spec driven development just using MbUnit. I&#8217;ve since gathered that there are lots of people doing this.</p>
<p>Recently I had to do a small sample application in a short period of time. It wasn&#8217;t for work (i.e. no MbUnit legacy) and I still wanted to do it spec first, so I grabbed the latest MSpec and used that.</p>
<p>I noticed there are several small but appreciated changes that have been made since the last time I used MSpec, namely:</p>
<h4>XUnit and (kind of) Gallio Support</h4>
<p>To use Gallio/MbUnit or xUnit with MSpec, there&#8217;s really nothing special to do - just reference the testing framework you want to use and the adapter assembly. </p>
<p>The adapter assembly is the magic part of MSpec. It helps the unit testing framework build a model of the tests to run. When using MSpec, you&#8217;re not putting attributes on things anymore to indicate they are unit tests. The adapter is needed so the unit testing framework knows what to run as tests.</p>
<p>For NUnit and xUnit, there are a bunch of nice extension methods defined for doing <em>systemUnderTest</em>.<em>ShouldXXX</em>() style assertions. There aren&#8217;t any for MbUnit, but I made <a href="http://github.com/cbilson/machine.specifications/blob/e922df9b5367072167694a6a887f6ece1aea518c/Source/Machine.Specifications.Example.UsingGallio/GallioExtensionMethods.cs">some</a> in <a href="http://github.com/cbilson/machine.specifications/tree/master">my fork of MSpec</a> if you&#8217;re interested. </p>
<p>I imagine you could write an adapter for MSTest, as well as some extension methods, but my interest in MSTest-ifying MSpec this ends there.</p>
<p>Once you start using these extension methods, the unit testing framework dependencies kind of melt away:</p>
<blockquote><pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> when_pricing_an_item_that_requires_no_sales_tax : with_an_item_to_price
{
    <span class="kwrd">static</span> Money price;

    Because of = () =&gt; {

        the_product.is_not_taxed()
                   .when_shipped_to(our_destination);

        price = pricingService.PriceItem(1, the_product, our_destination);
    };

    It prices_as_the_base_price = () =&gt;
        price.ShouldEqual(our_base_price);
}</pre>
</blockquote>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>Where&#8217;s the test framework code? Does this use NUnit? MbUnit? The only assertion here is in ShouldEqual, which is one of those extension methods that calls who cares which unit testing framework.</p>
<p>That&#8217;s the real lesson here: who cares which unit testing framework you&#8217;re using - that decision doesn&#8217;t add any value to your product, and doesn&#8217;t make this a valid excuse for not using MSpec. If one framework or the other works better with your build process or some tool you are using, just use that framework.</p>
<h4>Pending</h4>
<pre class="csharpcode">    <span class="kwrd">public</span> <span class="kwrd">class</span> when_pricing_an_item_that_requires_sales_tax_where_we_are_shipping : with_an_item_to_price
    {
            It includes_the_tax_in_the_price;
            It includes_the_tax_in_the_total_tax;
            It doesnt_include_the_tax_in_the_subtotal;
            It doesnt_include_the_tax_in_the_line_item_total;
    }</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>I saw Aaron demo this somewhere once, maybe at an #altnetseattle meeting or something, but I didn&#8217;t get it at first. I thought it was about going off and writing a bunch of <em>Tests</em> then implementing them. My view that you write one <em>Test</em>, then implement, then another, etc.</p>
<p>The difference is, when doing things <em>Spec</em> first, it&#8217;s&#8230;well&#8230;it&#8217;s just different. I think one reason I like one test at a time is that I am testing close to the implementation at that point. Since I am in the process of designing the system while doing TDD, I don&#8217;t know what the rest of the design is going to look like till I get there. If I write too many tests, I am speculating about what the design is going to look like.</p>
<p>Specs aren&#8217;t so much about the physical design of the system so they don&#8217;t change (as much) as the design evolves. If they do, they have good (read: business) reason. It&#8217;s not wrong to translate specs into code as part of the same process you are getting them (ex.: talking with a product owner&#8230;taking notes in the form of &quot;public class whatever_context { It does_this; It does_that; &#8230;}&quot;.) That process is unlikely to be as granular as TDD tests, as no business person that is making money wants to hold your hand all day while they spoon feed you one thing at a time.</p>
<p>The output from running the above specs is:</p>
<blockquote>
<pre><code>when pricing an item that requires sales tax where we are shipping
&gt;&gt; includes the tax in the price (NOT IMPLEMENTED)
&gt;&gt; the tax in the total tax (NOT IMPLEMENTED)
&gt;&gt; include the tax in the subtotal (NOT IMPLEMENTED)
&gt;&gt; include the tax in the line item total (NOT IMPLEMENTED)
</code></pre>
</blockquote>
<p>You can go ahead and spec things out ahead of time just saying &quot;It does_whatever&quot; and you&#8217;ll get a nice report of what&#8217;s to be done.</p>
<h4>Behavior</h4>
<p>This feature answers a question I&#8217;ve had since the first time I saw someone do BDD: What do you do when you want to specify the same behavior for multiple contexts?</p>
<blockquote>
<pre class="csharpcode">[Subject(<span class="str">&quot;Calculating sales tax&quot;</span>)]
<span class="kwrd">public</span> <span class="kwrd">class</span> when_an_item_is_a_kind_of_food : with_an_invoice_with_one_item
{
    Because of = () =&gt; invoice = <span class="kwrd">new</span> Invoice().WithSomeKindOf(Category.Food);
    Behaves_like&lt;NoSalesTaxAdded&gt; no_sales_tax_added;
}

[Subject(<span class="str">&quot;Calculating sales tax&quot;</span>)]
<span class="kwrd">public</span> <span class="kwrd">class</span> when_an_item_is_a_kind_of_medical_supply : with_an_invoice_with_one_item
{
    Because of = () =&gt; invoice = <span class="kwrd">new</span> Invoice().WithSomeKindOf(Category.MedicalSupplies);
    Behaves_like&lt;NoSalesTaxAdded&gt; no_sales_tax_added;
}

[Behaviors]
<span class="kwrd">public</span> <span class="kwrd">class</span> NoSalesTaxAdded
{
    <span class="kwrd">protected</span> <span class="kwrd">static</span> Invoice invoice;

    It has_no_sales_tax_added = () =&gt;
    {
        <span class="kwrd">foreach</span> (var item <span class="kwrd">in</span> invoice.Items)
            invoice.GetPostTaxValueFor(item).ShouldEqual(item.Value);
    };
}</pre>
</blockquote>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>In the samples that come with MSpec, there is an example of two implementations of the same interface, like a <a href="http://weblogs.asp.net/astopford/archive/2008/08/25/mbunit-typefixture.aspx">TypeFixture</a> in MbUnit. </p>
<p>It seems like, in the applications I work on, I rarely run across a need to use this kind of test, but I do sometimes need <a href="http://weblogs.asp.net/astopford/archive/2008/08/25/mbunit-rowtest.aspx">RowTest</a>-like tests, or, more often, <a href="http://weblogs.asp.net/astopford/archive/2008/08/26/mbunit-factory.aspx">factory</a> driven tests - like to specify that for a certain set of contexts, there is some behavior. My example above is a lame attempt to illustrate this.</p>
<h4>What&#8217;s Next</h4>
<p>That&#8217;s kind of the technical view of things. Hopefully I&#8217;ve gotten your attention and you are git clone-ing MSpec in the background right now. I hope to post part 2 of this in a couple of days, with some examples of how I use MSpec in real code.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ElegantCode?a=EeenODdoBrQ:8XUvm2J2d-Q:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ElegantCode?i=EeenODdoBrQ:8XUvm2J2d-Q:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=EeenODdoBrQ:8XUvm2J2d-Q:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=EeenODdoBrQ:8XUvm2J2d-Q:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=EeenODdoBrQ:8XUvm2J2d-Q:XAVGb8Xj5zA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=XAVGb8Xj5zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=EeenODdoBrQ:8XUvm2J2d-Q:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=G79ilh31hkQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ElegantCode/~4/EeenODdoBrQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/07/05/mspec-take-2/feed/</wfw:commentRss>
		</item>
		<item>
		<title>DELETE Documents from CouchDB</title>
		<link>http://elegantcode.com/2009/07/03/delete-documents-from-couchdb/</link>
		<comments>http://elegantcode.com/2009/07/03/delete-documents-from-couchdb/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 23:21:55 +0000</pubDate>
		<dc:creator>Jan Van Ryswyck</dc:creator>
		
		<category><![CDATA[CouchDB]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/07/03/delete-documents-from-couchdb/</guid>
		<description><![CDATA[To start off, here are the links to my previous posts about CouchDB:

Relaxing on the Couch(DB)
Installing the Couch(DB)
PUTting the Couch(DB) in Your Living Room
GETting Documents From CouchDB

Today, I want to talk about how to delete a document from CouchDB. In order to do that, we have to use the HTTP DELETE operation (how convenient). Removing [...]]]></description>
			<content:encoded><![CDATA[<p>To start off, here are the links to my previous posts about CouchDB:</p>
<ol>
<li><a href="http://elegantcode.com/2009/05/23/relaxing-on-the-couchdb/">Relaxing on the Couch(DB)</a></li>
<li><a href="http://elegantcode.com/2009/05/30/installing-the-couchdb/">Installing the Couch(DB)</a></li>
<li><a href="http://elegantcode.com/2009/07/01/putting-the-couchdb-in-your-living-room/">PUTting the Couch(DB) in Your Living Room</a></li>
<li><a href="http://elegantcode.com/2009/07/02/getting-documents-from-couchdb/" target="_blank">GETting Documents From CouchDB</a></li>
</ol>
<p>Today, I want to talk about how to delete a document from CouchDB. In order to do that, we have to use the HTTP DELETE operation (how convenient). Removing a document from CouchDB can be done using the following request:</p>
<pre class="csharpcode">DELETE /documentstore/13ce4780-62c8-4074-9955-8c99966b84bb
?rev=1-2901013762</pre>
<p>This makes CouchDB return the following response:</p>
<pre class="csharpcode">{
<span class="str">"ok"</span>:<span class="kwrd">true</span>,
<span class="str">"id"</span>:<span class="str">"13ce4780-62c8-4074-9955-8c99966b84bb"</span>,
<span class="str">"rev"</span>:<span class="str">"2-3500205450"</span>
}</pre>
<p>This confirms that the document has been removed by CouchDB. But is it really gone? Not exactly. We might be able to retrieve it using its revision number. Sending the following request:</p>
<p><!-- .csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<pre class="csharpcode">GET /documentstore/13ce4780-62c8-4074-9955-8c99966b84bb
?rev=2-3500205450</pre>
<p><!-- .csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<p>still indicates that the document we just deleted still exists:</p>
<pre class="csharpcode">{
<span class="str">"_id"</span>:<span class="str">"13ce4780-62c8-4074-9955-8c99966b84bb"</span>,
<span class="str">"_rev"</span>:<span class="str">"2-3500205450"</span>,
<span class="str">"_deleted"</span>:<span class="kwrd">true</span>
}</pre>
<p><!-- .csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<p>Notice that the <em>_deleted</em> attribute indicates that the document has indeed been deleted. It&#8217;s even possible to resurrect the document at hand by performing an update, bringing the document back amongst the living documents.</p>
<p>However, I don&#8217;t consider that a good idea in all scenarios. In fact, as pointed out by <a href="http://elegantcode.com/2009/07/02/getting-documents-from-couchdb/#comment-47440" target="_blank">this comment</a> on my previous post, one should not blindly rely on the MVCC tokens for version control of documents, something that I neglected to point out in that post. <strong>When CouchDB is configured for compaction or replication with other instances of CouchDB, then this approach is not recommended.</strong> In case of compaction , CouchDB will actively purge old versions of documents and deleted documents. In case of replication, a particular node in a clustered environment doesn&#8217;t necessarily have the complete version history of a document. Bottom line, use this feature very carefully.</p>
<p>For my next post, I will talk about how to create attachment for a document.</p>
<p>Till next time</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ElegantCode?a=JVzioWgcfoA:I3JQ42OG4rk:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ElegantCode?i=JVzioWgcfoA:I3JQ42OG4rk:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=JVzioWgcfoA:I3JQ42OG4rk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=JVzioWgcfoA:I3JQ42OG4rk:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=JVzioWgcfoA:I3JQ42OG4rk:XAVGb8Xj5zA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=XAVGb8Xj5zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=JVzioWgcfoA:I3JQ42OG4rk:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=G79ilh31hkQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ElegantCode/~4/JVzioWgcfoA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/07/03/delete-documents-from-couchdb/feed/</wfw:commentRss>
		</item>
		<item>
		<title>WPF Multithreading: Using the BackgroundWorker and Reporting the Progress to the UI.</title>
		<link>http://elegantcode.com/2009/07/03/wpf-multithreading-using-the-backgroundworker-and-reporting-the-progress-to-the-ui/</link>
		<comments>http://elegantcode.com/2009/07/03/wpf-multithreading-using-the-backgroundworker-and-reporting-the-progress-to-the-ui/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 07:53:39 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
		
		<category><![CDATA[.Net 3.5]]></category>

		<category><![CDATA[C#]]></category>

		<category><![CDATA[WPF]]></category>

		<category><![CDATA[background worker]]></category>

		<category><![CDATA[multithreading]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/07/03/wpf-multithreading-using-the-backgroundworker-and-reporting-the-progress-to-the-ui/</guid>
		<description><![CDATA[I can’t count the number of times someone has asked me about running a time consuming task on a separate thread, but at the same time show a progress dialog with up-to-the-second percentage updates being displayed to the user. Multithreading can be confusing at first, but if you just take it one step at a [...]]]></description>
			<content:encoded><![CDATA[<p>I can’t count the number of times someone has asked me about running a time consuming task on a separate thread, but at the same time show a progress dialog with up-to-the-second percentage updates being displayed to the user. Multithreading can be confusing at first, but if you just take it one step at a time, it really isn’t all that bad. I am going to show you how to create a multithreaded application that shows a progress dialog which shows real time progress to the user. </p>
<p>First lets start with how to get started with multithreading in WPF. If you don’t want to read how this actually works and just want to get the source and start playing ,here is the <a href="http://www.brianlagunas.com/downloads/source/multithreading.zip">Source Code</a>.</p>
<p>Your WPF application may need to perform intensive tasks that consume large amounts of time. Executing these tasks on a separate thread allows you to maintain the responsiveness of the UI while the task is performed. Enter the BackgroundWorker. The BackgroundWorker is the recommended way to run time consuming tasks on a separate, dedicated thread, leaving the UI responsive. </p>
<p><strong>Running a Background Process</strong></p>
<p>The RunWorkerAsync method starts the execution of the background process by raising the DoWork event. The code in the DoWork event handler is executed on a separate thread.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">int</span> maxRecords = 1000;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">&#160;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">BackgroundWorker worker = <span style="color: #0000ff">new</span> BackgroundWorker();</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">&#160;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">worker.DoWork += <span style="color: #0000ff">delegate</span>(<span style="color: #0000ff">object</span> s, DoWorkEventArgs args)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">{</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> x = 1; x &lt; maxRecords; x++)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">        System.Threading.Thread.Sleep(10);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">};</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">&#160;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">worker.RunWorkerAsync();</pre>
</p></div>
</div>
<p><strong>Providing Parameters to the Process</strong></p>
<p>Your background process may required one or more parameters, such as the address of a file to download. You can provide a parameter in the RunWorkerAsync method that will be available as the Argument property in the DoWork event handler.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">BackgroundWorker worker = <span style="color: #0000ff">new</span> BackgroundWorker();</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">&#160;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">worker.DoWork += <span style="color: #0000ff">delegate</span>(<span style="color: #0000ff">object</span> s, DoWorkEventArgs args)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">{</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #0000ff">string</span> path = (<span style="color: #0000ff">string</span>)args.Argument;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #008000">//do something</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">};</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">&#160;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">worker.RunWorkerAsync(<span style="color: #006080">&quot;c:\\myFile.txt&quot;</span>);</pre>
</p></div>
</div>
<p><strong>Returning a Value from the Process</strong></p>
<p>You might want to return a value from a background process, such as a result from a calculation. You can return a value by setting the Result property of the DoWorkEventArgs in the DoWork event handler. Then, this value can be retrieved from the Result property of the RunWorkerCompletedEventArgs parameter int the RunWorkerCompleted event handler.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">BackgroundWorker worker = <span style="color: #0000ff">new</span> BackgroundWorker();</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">&#160;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">worker.DoWork += <span style="color: #0000ff">delegate</span>(<span style="color: #0000ff">object</span> s, DoWorkEventArgs args)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">{</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    args.Result = CalculationMethod();</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">};</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">&#160;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">worker.RunWorkerCompleted += <span style="color: #0000ff">delegate</span>(<span style="color: #0000ff">object</span> s, RunWorkerCompletedEventArgs args)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">{</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #0000ff">object</span> result = args.Result;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">};</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">&#160;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">worker.RunWorkerAsync();</pre>
</p></div>
</div>
<p><strong>Cancelling the Background Process</strong></p>
<p>You may want to allow the user to cancel a long running process. In order to support this you must first set the WorkerSupportsCancellation to true. You call the CancelAsync mtehod to attempt to cancel the process. When you call the CancelAsync method it sets the CancellationPending property of the BackgroundWorker to true. Then you must check for the value of the CancellationPending property in the DoWork event handler, and if it is true, set the Cancel property of the DoWorkEventArgs parameter to true.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">int</span> maxRecords = 1000;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">&#160;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">BackgroundWorker worker = <span style="color: #0000ff">new</span> BackgroundWorker();</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">worker.WorkerSupportsCancellation = <span style="color: #0000ff">true</span>;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">&#160;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">worker.DoWork += <span style="color: #0000ff">delegate</span>(<span style="color: #0000ff">object</span> s, DoWorkEventArgs args)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">{</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> x = 1; x &lt; maxRecords; x++)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        <span style="color: #008000">//check if there is a cancelat</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">        <span style="color: #0000ff">if</span> (worker.CancellationPending)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">            args.Cancel = <span style="color: #0000ff">true</span>;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">            <span style="color: #0000ff">return</span>;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">        }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">&#160;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">        System.Threading.Thread.Sleep(10);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">};</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">&#160;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">worker.RunWorkerAsync();</pre>
</p></div>
</div>
<p><strong>Reporting the Progress of a Background Process</strong></p>
<p>You can report the progress of a background process back to the primary thread by calling the ReportProgress method. This method raises the ProgressChanged event and allows you to pass a parameter that indicated the percentage of progress that has been completed. Make sure you set the WorkerReportsProgess property of the BackgroundWorker to true.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">int</span> maxRecords = 1000;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">&#160;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">BackgroundWorker worker = <span style="color: #0000ff">new</span> BackgroundWorker();</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">worker.WorkerReportsProgress = <span style="color: #0000ff">true</span>;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">&#160;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">worker.DoWork += <span style="color: #0000ff">delegate</span>(<span style="color: #0000ff">object</span> s, DoWorkEventArgs args)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">{</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> x = 1; x &lt; maxRecords; x++)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        System.Threading.Thread.Sleep(10);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">        worker.ReportProgress(Convert.ToInt32(((<span style="color: #0000ff">decimal</span>)x / (<span style="color: #0000ff">decimal</span>)maxRecords) * 100));</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">};</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">&#160;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">worker.ProgressChanged += <span style="color: #0000ff">delegate</span>(<span style="color: #0000ff">object</span> s, ProgressChangedEventArgs args)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">{</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #0000ff">int</span> percentage = args.ProgressPercentage;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">};</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">&#160;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">worker.RunWorkerAsync();</pre>
</p></div>
</div>
<p><strong>Using the Dispatcher to Access Controls on Another Thread</strong></p>
<p>At times, you may want to change the user interface from a worker thread. For example, you may want to enable or disable buttons, or show a modal ProgressBar that provides more detailed progress information than is allowed by the ReportProgress method. The WPF threading model provides the Dispatcher class for cross thread calls. By using the Dispatcher, you can safely update your user interface from background worker threads.</p>
<p>You can get a reference to the Dispacther object for a UI element from its Dispatcher property.<br />
  </p>
<div>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">System.Windows.Threading.Dispatcher aDisp = Button1.Dispatcher;</pre>
</div>
<p>Dispatcher provides two main methods that you will use; Invoke and BeginInvoke. Both methods allows you to call a method safely on the UI thread. The BeginInvoke method allows you to call a method asynchronously, and the Invoke method allows you to call a method synchronously.</p>
<p><strong>Putting It All Together</strong></p>
<p>Lets say I have a time consuming task in my application.&#160; I want to execute this time consuming task on a background thread, but I also want to show a modal progress dialog that shows a message and the percent of the completed task. I also want to allow the user to cancel the process at anytime. So the first thing I need to do is create my progress dialog window that has a label to display my percent completed, a progress bar to graphically show the progress, and a cancel button so the user can cancel the process.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">&lt;</span><span style="color: #800000">Window</span> <span style="color: #ff0000">x:Class</span><span style="color: #0000ff">=&quot;MultiThreading.ProgressDialog&quot;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #ff0000">xmlns</span><span style="color: #0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #ff0000">xmlns:x</span><span style="color: #0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #ff0000">Title</span><span style="color: #0000ff">=&quot;ProgressDialog&quot;</span> <span style="color: #ff0000">Height</span><span style="color: #0000ff">=&quot;115&quot;</span> <span style="color: #ff0000">Width</span><span style="color: #0000ff">=&quot;300&quot;</span> <span style="color: #ff0000">WindowStyle</span><span style="color: #0000ff">=&quot;ToolWindow&quot;</span> <span style="color: #ff0000">WindowStartupLocation</span><span style="color: #0000ff">=&quot;CenterOwner&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #0000ff">&lt;</span><span style="color: #800000">Grid</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        <span style="color: #0000ff">&lt;</span><span style="color: #800000">StackPanel</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">            <span style="color: #0000ff">&lt;</span><span style="color: #800000">Label</span> <span style="color: #ff0000">x:Name</span><span style="color: #0000ff">=&quot;lblProgress&quot;</span> <span style="color: #ff0000">Content</span><span style="color: #0000ff">=&quot;0%&quot;</span><span style="color: #0000ff">/&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">            <span style="color: #0000ff">&lt;</span><span style="color: #800000">ProgressBar</span> <span style="color: #ff0000">x:Name</span><span style="color: #0000ff">=&quot;progress&quot;</span> <span style="color: #ff0000">Height</span><span style="color: #0000ff">=&quot;25&quot;</span> <span style="color: #ff0000">IsIndeterminate</span><span style="color: #0000ff">=&quot;False&quot;</span><span style="color: #0000ff">&gt;&lt;/</span><span style="color: #800000">ProgressBar</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">            <span style="color: #0000ff">&lt;</span><span style="color: #800000">StackPanel</span> <span style="color: #ff0000">Orientation</span><span style="color: #0000ff">=&quot;Horizontal&quot;</span> <span style="color: #ff0000">HorizontalAlignment</span><span style="color: #0000ff">=&quot;Right&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">                <span style="color: #0000ff">&lt;</span><span style="color: #800000">Button</span> <span style="color: #ff0000">x:Name</span><span style="color: #0000ff">=&quot;btnCancel&quot;</span> <span style="color: #ff0000">Click</span><span style="color: #0000ff">=&quot;btnCancel_Click&quot;</span><span style="color: #0000ff">&gt;</span>Cancel<span style="color: #0000ff">&lt;/</span><span style="color: #800000">Button</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">            <span style="color: #0000ff">&lt;/</span><span style="color: #800000">StackPanel</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        <span style="color: #0000ff">&lt;/</span><span style="color: #800000">StackPanel</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #0000ff">&lt;/</span><span style="color: #800000">Grid</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">&lt;/</span><span style="color: #800000">Window</span><span style="color: #0000ff">&gt;</span></pre>
</p></div>
</div>
<p>I need to expose two properties; ProgressText to set my label, and ProgressValue to set the progress bar value. I also need to expose an event so when the user hits the cancel button the process will stop.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> <span style="color: #0000ff">public</span> <span style="color: #0000ff">string</span> ProgressText</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span> {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span>     set</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span>     {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span>         <span style="color: #0000ff">this</span>.lblProgress.Content = <span style="color: #0000ff">value</span>;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span>     }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span> }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span>&#160; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span> <span style="color: #0000ff">public</span> <span style="color: #0000ff">int</span> ProgressValue</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span> {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span>     set</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  12:</span>     {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  13:</span>         <span style="color: #0000ff">this</span>.progress.Value = <span style="color: #0000ff">value</span>;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  14:</span>     }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  15:</span> }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  16:</span>&#160; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  17:</span> <span style="color: #0000ff">public</span> <span style="color: #0000ff">event</span> EventHandler Cancel = <span style="color: #0000ff">delegate</span> { };</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  18:</span>&#160; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  19:</span> <span style="color: #0000ff">private</span> <span style="color: #0000ff">void</span> btnCancel_Click(<span style="color: #0000ff">object</span> sender, RoutedEventArgs e)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  20:</span> {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  21:</span>     Cancel(sender, e);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  22:</span> }</pre>
</p></div>
</div>
<p>Now on my main application I need a button to execute this long running process and show my progress dialog.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; height: 36px; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">&lt;</span><span style="color: #800000">Button</span> <span style="color: #ff0000">Height</span><span style="color: #0000ff">=&quot;23&quot;</span> <span style="color: #ff0000">Name</span><span style="color: #0000ff">=&quot;btnDispacther&quot;</span> <span style="color: #ff0000">Click</span><span style="color: #0000ff">=&quot;btnDispacther_Click&quot;</span><span style="color: #0000ff">&gt;</span>Using Dispatcher<span style="color: #0000ff">&lt;/</span><span style="color: #800000">Button</span><span style="color: #0000ff">&gt;</span></pre>
</p></div>
</div>
<p>Now lets code the background worker.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #008000">//our bg worker</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">BackgroundWorker worker;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #008000">//our progress dialog window</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">ProgressDialog pd;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">&#160;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">private</span> <span style="color: #0000ff">void</span> btnDispacther_Click(<span style="color: #0000ff">object</span> sender, RoutedEventArgs e)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">{</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #0000ff">int</span> maxRecords = 1000;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">&#160;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    pd = <span style="color: #0000ff">new</span> ProgressDialog();</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">&#160;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #008000">//hook into the cancel event</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    pd.Cancel += CancelProcess;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">&#160;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #008000">//get our dispatcher</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    System.Windows.Threading.Dispatcher pdDispatcher = pd.Dispatcher;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">&#160;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #008000">//create our background worker and support cancellation</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    worker = <span style="color: #0000ff">new</span> BackgroundWorker();</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    worker.WorkerSupportsCancellation = <span style="color: #0000ff">true</span>;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">&#160;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    worker.DoWork += <span style="color: #0000ff">delegate</span>(<span style="color: #0000ff">object</span> s, DoWorkEventArgs args)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> x = 1; x &lt; maxRecords; x++)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">        {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">            <span style="color: #0000ff">if</span> (worker.CancellationPending)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">            {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">                args.Cancel = <span style="color: #0000ff">true</span>;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">                <span style="color: #0000ff">return</span>;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">            }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">&#160;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">            System.Threading.Thread.Sleep(10);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">&#160;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">            <span style="color: #008000">//create a new delegate for updating our progress text</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">            UpdateProgressDelegate update = <span style="color: #0000ff">new</span> UpdateProgressDelegate(UpdateProgressText);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">&#160;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">            <span style="color: #008000">//invoke the dispatcher and pass the percentage and max record count</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">            pdDispatcher.BeginInvoke(update, Convert.ToInt32(((<span style="color: #0000ff">decimal</span>)x / (<span style="color: #0000ff">decimal</span>)maxRecords) * 100), maxRecords);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">        }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    };</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">&#160;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    worker.RunWorkerCompleted += <span style="color: #0000ff">delegate</span>(<span style="color: #0000ff">object</span> s, RunWorkerCompletedEventArgs args)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        pd.Close();</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    };</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">&#160;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #008000">//run the process then show the progress dialog</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    worker.RunWorkerAsync();</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    pd.ShowDialog();</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">}</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">&#160;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #008000">//our delegate used for updating the UI</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">public</span> <span style="color: #0000ff">delegate</span> <span style="color: #0000ff">void</span> UpdateProgressDelegate(<span style="color: #0000ff">int</span> percentage, <span style="color: #0000ff">int</span> recordCount);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">&#160;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #008000">//this is the method that the deleagte will execute</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> UpdateProgressText(<span style="color: #0000ff">int</span> percentage, <span style="color: #0000ff">int</span> recordCount)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">{</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #008000">//set our progress dialog text and value</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    pd.ProgressText = <span style="color: #0000ff">string</span>.Format(<span style="color: #006080">&quot;{0}% of {1} Records&quot;</span>, percentage.ToString(), recordCount);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    pd.ProgressValue = percentage;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">}</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">&#160;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">void</span> CancelProcess(<span style="color: #0000ff">object</span> sender, EventArgs e)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">{</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #008000">//cancel the process</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    worker.CancelAsync();</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">}</pre>
</p></div>
</div>
<p>That’s it. See, I told you it wasn’t that bad. Now that you have a basic understanding of multithreading, try to see how creative you can get on implementing it in your WPF application.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ElegantCode?a=35_HX3uaUWQ:AfjDmYP1Q-w:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ElegantCode?i=35_HX3uaUWQ:AfjDmYP1Q-w:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=35_HX3uaUWQ:AfjDmYP1Q-w:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=35_HX3uaUWQ:AfjDmYP1Q-w:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=35_HX3uaUWQ:AfjDmYP1Q-w:XAVGb8Xj5zA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=XAVGb8Xj5zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=35_HX3uaUWQ:AfjDmYP1Q-w:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=G79ilh31hkQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ElegantCode/~4/35_HX3uaUWQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/07/03/wpf-multithreading-using-the-backgroundworker-and-reporting-the-progress-to-the-ui/feed/</wfw:commentRss>
		</item>
		<item>
		<title>EQATEC Profiler and .net cf Profiling (and regular .net)</title>
		<link>http://elegantcode.com/2009/07/02/eqatec-profiler-and-net-cf-profiling-and-regular-net/</link>
		<comments>http://elegantcode.com/2009/07/02/eqatec-profiler-and-net-cf-profiling-and-regular-net/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 22:50:22 +0000</pubDate>
		<dc:creator>Chris Brandsma</dc:creator>
		
		<category><![CDATA[Esoterica]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/07/02/eqatec-profiler-and-net-cf-profiling-and-regular-net/</guid>
		<description><![CDATA[.net Compact Framework is known for missing several “features” that regular .net developers take for granted.&#160; One if the ready availability of profilers.&#160; dotTrace, ANTS Performance Profiler, Team Systems Profiler (check out Visual Studio 2010 version of this…much better).&#160; There are other profilers out there, but those are the three I am most familiar with.
What [...]]]></description>
			<content:encoded><![CDATA[<p>.net Compact Framework is known for missing several “features” that regular .net developers take for granted.&#160; One if the ready availability of profilers.&#160; <a href="http://www.jetbrains.com/profiler/index.html">dotTrace</a>, <a href="http://www.red-gate.com/products/ants_performance_profiler/index.htm">ANTS Performance Profiler</a>, Team Systems Profiler (check out Visual Studio 2010 version of this…much better).&#160; There are other profilers out there, but those are the three I am most familiar with.</p>
<p>What all of those have in common is that none of them will profile .net Compact Framework.&#160; But I found a profiler yesterday that does, plus it is free: <a href="http://www.eqatec.com/tools/profiler">EQATEC Profiler</a>.&#160; </p>
<p><a href="http://elegantcode.com/wp-content/uploads/2009/07/image.png" target="_blank"><img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="image" border="0" alt="image" align="right" src="http://elegantcode.com/wp-content/uploads/2009/07/image-thumb.png" width="244" height="185" /></a> The basics of how to use this profiler is to “point” the profiler at your application (the executable, not the source), then use the Profiler “build”.&#160; What happens here is the profiler modifies your executable to include new tracing/logging for the profiler, but in a different directory (a *-Profiled directory).</p>
<p>If you look in the Profiling options you will see a directory where the profile logs are written. Note: the log is an xml file in the form of an *.eqlog file. </p>
<p>Now, if you are running a plain-Jane .net desktop executable, you can just click run and start profiling.&#160; If you are running a .net cf executable you need to do a little more work.&#160;&#160; The little more work is connect your device/emulator to you operating system, and copy the profile-enabled executables to the device.&#160; Then manually run the executable on the device.&#160; Once done, find the *.eqlog file on the device and copy it to your host machine.&#160; From there you can simply double click the log file and analyze the results.</p>
<p><a href="http://elegantcode.com/wp-content/uploads/2009/07/image1.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="image" border="0" alt="image" align="right" src="http://elegantcode.com/wp-content/uploads/2009/07/image-thumb1.png" width="244" height="217" /></a>&#160; Here is what you get in return.&#160; The report includes:</p>
<ul>
<li>Total(full)Total number of milliseconds a method took to run in each case.&#160; Includes calls to child methods</li>
<li>Avg(full) Average number of milliseconds each call of the method took to run</li>
<li>Total(self) Total number of milliseconds a method took to run, excluding child calls</li>
<li>Avg(self) Average number of time the method took per call</li>
<li>Calls – Total number of calls to the method</li>
<li>Method Name (why is this last?)</li>
</ul>
<p>Note: <a href="http://elegantcode.com/wp-content/uploads/2009/07/index.htm">go to the Help page for more details</a>.</p>
<p>The pretty picture in the Details portion of the UI is an interactive call stack browser.</p>
<p>OK, so is this enough? Yes, but it is 100% that what I was able to get.&#160; Even though the results are somewhat simplistic, it is still very useful.&#160; I was able to find where I had some performance problems.&#160; I would love to have a UI to compare profile runs, but this will do for now.</p>
<p>One other thing this profiler does not do is Memory Profiling (NetCFCLRProfiler.exe, once installed, found at C:\Program Files\Microsoft.NET\SDK\CompactFramework\v3.5\bin).&#160; Fortunately there is one in the <a href="http://www.microsoft.com/downloads/details.aspx?familyid=C8174C14-A27D-4148-BF01-86C2E0953EAB&amp;displaylang=en">Power Toys for .Net Compact Framework 3.5</a>.&#160; If I get some time I’ll go over that one later.</p>
<p>Also, for further info on profiling .net cf applications, <a href="http://blogs.msdn.com/davidklinems/archive/2005/12/09/502125.aspx">check out this post by David Kline</a>.    </p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ElegantCode?a=yqUA5t6BW6o:v24TF63HIwA:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ElegantCode?i=yqUA5t6BW6o:v24TF63HIwA:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=yqUA5t6BW6o:v24TF63HIwA:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=yqUA5t6BW6o:v24TF63HIwA:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=yqUA5t6BW6o:v24TF63HIwA:XAVGb8Xj5zA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=XAVGb8Xj5zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=yqUA5t6BW6o:v24TF63HIwA:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=G79ilh31hkQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ElegantCode/~4/yqUA5t6BW6o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/07/02/eqatec-profiler-and-net-cf-profiling-and-regular-net/feed/</wfw:commentRss>
		</item>
		<item>
		<title>GETting Documents From CouchDB</title>
		<link>http://elegantcode.com/2009/07/02/getting-documents-from-couchdb/</link>
		<comments>http://elegantcode.com/2009/07/02/getting-documents-from-couchdb/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 19:22:23 +0000</pubDate>
		<dc:creator>Jan Van Ryswyck</dc:creator>
		
		<category><![CDATA[CouchDB]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/07/02/getting-documents-from-couchdb/</guid>
		<description><![CDATA[To start off, here are the links to my previous posts about CouchDB:

Relaxing on the Couch(DB)
Installing the Couch(DB)
PUTting the Couch(DB) in Your Living Room

In my latest post, I explained how easy it is to create and manage documents in CouchDB. Today, I want to talk about how to retrieve a document from CouchDB.
In order to [...]]]></description>
			<content:encoded><![CDATA[<p>To start off, here are the links to my previous posts about CouchDB:</p>
<ol>
<li><a href="http://elegantcode.com/2009/05/23/relaxing-on-the-couchdb/">Relaxing on the Couch(DB)</a></li>
<li><a href="http://elegantcode.com/2009/05/30/installing-the-couchdb/">Installing the Couch(DB)</a></li>
<li><a href="http://elegantcode.com/2009/07/01/putting-the-couchdb-in-your-living-room/" target="_blank">PUTting the Couch(DB) in Your Living Room</a></li>
</ol>
<p>In my <a href="http://elegantcode.com/2009/07/01/putting-the-couchdb-in-your-living-room/" target="_blank">latest post</a>, I explained how easy it is to create and manage documents in CouchDB. Today, I want to talk about how to retrieve a document from CouchDB.</p>
<p>In order to retrieve a document from CouchDB, we make use of the HTTP GET operation (duh). Using the GET method for retrieving a document takes the following general form:</p>
<p><a href="http://myhost:5984/my_database/my_id">http://myhost:5984/my_database/my_id</a></p>
<p>Its as simple as that. So, for example, sending the following request:</p>
<pre class="csharpcode">GET /documentstore/96f49e5a-6b5b-47ed-9234-9a98d600013e</pre>
<p><!-- .csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<p>makes CouchDB return the following response:</p>
<pre class="csharpcode">{
<span class="str">"_id"</span>:<span class="str">"96f49e5a-6b5b-47ed-9234-9a98d600013e"</span>,
<span class="str">"_rev"</span>:<span class="str">"2-1534297415"</span>,
<span class="str">"Author"</span>:<span class="str">"Stephen Hawking"</span>,
<span class="str">"Title"</span>:<span class="str">"The Universe in a Nutshell"</span>,
<span class="str">"Tags"</span>:[{<span class="str">"Name"</span>:<span class="str">"Physics"</span>},{<span class="str">"Name"</span>:<span class="str">"Universe"</span>},{<span class="str">"Name"</span>:<span class="str">"Space"</span>}]
}</pre>
<p><!-- .csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<p>As already mentioned, CouchDB provides MVCC (multi-version concurrency control) for the documents it stores. Using the GET operation makes it possible to take advantage of this built-in feature. Notice that the first digit of the revision number in the example above indicates that this is the second version of the document we retrieved. This means that CouchDB possibly has an earlier version of the document. In order to find out what revisions are available, we can issue the following request:</p>
<pre class="csharpcode">GET /documentstore/96f49e5a-6b5b-47ed-9234-9a98d600013e?revs=<span class="kwrd">true</span></pre>
<p><!-- .csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<p>CouchDB returns the current revision of the document as before, but now with an additional field named <em>_revisions</em>:</p>
<pre class="csharpcode">{
<span class="str">"_id"</span>:<span class="str">"96f49e5a-6b5b-47ed-9234-9a98d600013e"</span>,
<span class="str">"_rev"</span>:<span class="str">"2-1534297415"</span>,
<span class="str">"Author"</span>:<span class="str">"Stephen Hawking"</span>,
<span class="str">"Title"</span>:<span class="str">"The Universe in a Nutshell"</span>,
<span class="str">"Tags"</span>:[{<span class="str">"Name"</span>:<span class="str">"Physics"</span>},{<span class="str">"Name"</span>:<span class="str">"Universe"</span>},{<span class="str">"Name"</span>:<span class="str">"Space"</span>}],
<span class="str">"_revisions"</span>:{<span class="str">"start"</span>:2,<span class="str">"ids"</span>:[<span class="str">"1534297415"</span>,<span class="str">"3158114761"</span>]},
}</pre>
<p><!-- .csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<p>In order to retrieve the first revision of our document, we can send the following request to retrieve it:</p>
<pre class="csharpcode">GET /documentstore/96f49e5a-6b5b-47ed-9234-9a98d600013e?rev=1-3158114761</pre>
<p><!-- .csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<p>As expected, CouchDB now returns the first revision of the document:</p>
<pre class="csharpcode">{
<span class="str">"_id"</span>:<span class="str">"96f49e5a-6b5b-47ed-9234-9a98d600013e"</span>,
<span class="str">"_rev"</span>:<span class="str">"1-3158114761"</span>,
<span class="str">"Author"</span>:<span class="str">"Stephen Hawking"</span>,
<span class="str">"Title"</span>:<span class="str">"The Universe in a Nutshell"</span>,
<span class="str">"Tags"</span>:[{<span class="str">"Name"</span>:<span class="str">"Physics"</span>},{<span class="str">"Name"</span>:<span class="str">"Universe"</span>}]
}</pre>
<p><!-- .csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<p>It seems that for the second revision of the document, we have added an extra tag. Having this kind of automatic versioning for your data is a really nice feature in my book.</p>
<p>For my next post, I will talk about how to delete a document from CouchDB..</p>
<p>Till next time</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ElegantCode?a=HUvpvaFfk6c:ITEwIo4X8mg:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ElegantCode?i=HUvpvaFfk6c:ITEwIo4X8mg:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=HUvpvaFfk6c:ITEwIo4X8mg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=HUvpvaFfk6c:ITEwIo4X8mg:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=HUvpvaFfk6c:ITEwIo4X8mg:XAVGb8Xj5zA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=XAVGb8Xj5zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=HUvpvaFfk6c:ITEwIo4X8mg:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=G79ilh31hkQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ElegantCode/~4/HUvpvaFfk6c" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/07/02/getting-documents-from-couchdb/feed/</wfw:commentRss>
		</item>
		<item>
		<title>JQuery: Playing with Select (DropDownList/ComboBox)</title>
		<link>http://elegantcode.com/2009/07/01/jquery-playing-with-select-dropdownlistcombobox/</link>
		<comments>http://elegantcode.com/2009/07/01/jquery-playing-with-select-dropdownlistcombobox/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 04:34:18 +0000</pubDate>
		<dc:creator>Chris Brandsma</dc:creator>
		
		<category><![CDATA[Esoterica]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/07/01/jquery-playing-with-select-dropdownlistcombobox/</guid>
		<description><![CDATA[Why oh why did the HTML overlords call their Combo Box/DropDownList a SELECT?&#160; Then call the items in the list OPTIONS?&#160; It isn’t like there weren’t a plethora of other names for the widget.&#160; Then it could have been consistent anyway.
Oh well.
It seams that each time I start a new project I have to relearn [...]]]></description>
			<content:encoded><![CDATA[<p>Why oh why did the HTML overlords call their Combo Box/DropDownList a SELECT?&#160; Then call the items in the list OPTIONS?&#160; It isn’t like there weren’t a plethora of other names for the widget.&#160; Then it could have been consistent anyway.</p>
<p>Oh well.</p>
<p>It seams that each time I start a new project I have to relearn how to grab values out of a DropDownList – I mean “select element”.&#160; Anyway, I’m trying to get this down before I go nuts and have to learn it all over again.</p>
<h2>Basic Select</h2>
<p>First off, here is the basic html I’m talking about:</p>
<div style="border-bottom: gray 1px solid; border-left: gray 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: gray 1px solid; cursor: text; border-right: gray 1px solid; padding-top: 4px">
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   1:</span> &lt;select id=<span style="color: #006080">&quot;ComboBox&quot;</span> &gt;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   2:</span>       &lt;option <span style="color: #0000ff">value</span>=<span style="color: #006080">&quot;1&quot;</span>&gt;Value 1&lt;/option&gt;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   3:</span>       &lt;option <span style="color: #0000ff">value</span>=<span style="color: #006080">&quot;2&quot;</span>&gt;Value 2&lt;/option&gt;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   4:</span>       &lt;option <span style="color: #0000ff">value</span>=<span style="color: #006080">&quot;3&quot;</span>&gt;Value 3&lt;/option&gt;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   5:</span>       &lt;option <span style="color: #0000ff">value</span>=<span style="color: #006080">&quot;4&quot;</span>&gt;Value 4&lt;/option&gt;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   6:</span>       &lt;optgroup label=<span style="color: #006080">&quot;Group1&quot;</span>&gt;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   7:</span>         &lt;option <span style="color: #0000ff">value</span>=<span style="color: #006080">&quot;5&quot;</span>&gt;Value 5&lt;/option&gt;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   8:</span>         &lt;option <span style="color: #0000ff">value</span>=<span style="color: #006080">&quot;6&quot;</span>&gt;Value 6&lt;/option&gt;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   9:</span>         &lt;option <span style="color: #0000ff">value</span>=<span style="color: #006080">&quot;7&quot;</span>&gt;Value 7&lt;/option&gt;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  10:</span>         &lt;option <span style="color: #0000ff">value</span>=<span style="color: #006080">&quot;8&quot;</span>&gt;Value 8&lt;/option&gt;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  11:</span>       &lt;/optgroup&gt;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  12:</span>     &lt;/select&gt;</pre>
</p></div>
</div>
<p>
<select id="ComboBox"> <option value="1">Value 1</option> <option value="2">Value 2</option> <option value="3">Value 3</option> <option value="4">Value 4</option> <optgroup label="Group1"> <option value="5">Value 5</option> <option value="6">Value 6</option> <option value="7">Value 7</option> <option value="8">Value 8</option> </optgroup></select>
<p> Nice and simple.&#160; Now, the basic things you want to do with said select statement:</p>
<p>1. Get the value of the selected item.<br />
  <br />2. Get the text of the selected item.</p>
<p>3. Find out when the value changed</p>
<p>4. Programmatically set the selected item.</p>
<p>5. Modify the list.</p>
<p>Most of those are very easy with JQuery, but one is slightly strange. Lets go through these one by one:</p>
<h2>1. Get the value of the selected item </h2>
<p>This is the easiest.&#160; Use the val method.&#160; All done.</p>
<div style="border-bottom: gray 1px solid; border-left: gray 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: gray 1px solid; cursor: text; border-right: gray 1px solid; padding-top: 4px">
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   1:</span> $(<span style="color: #006080">&quot;#ComboBox&quot;</span>).val()</pre>
</p></div>
</div>
<h2>2. Get the text of the selected item</h2>
<p>You would think this would be easy as well, but it isn’t.&#160; You cannot just use the text() method on the combobox.&#160; That will give you the text values of all of the options in a single string.&#160; Not what you want.&#160; The trick is to use the :selected query modifier on the option.</p>
<div style="border-bottom: gray 1px solid; border-left: gray 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: gray 1px solid; cursor: text; border-right: gray 1px solid; padding-top: 4px">
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   1:</span> $(<span style="color: #006080">&quot;#ComboBox option:selected&quot;</span>).text()</pre>
</p></div>
</div>
<p>Now, you might be tempted to use the ‘&gt;’ (means direct descendent of) between the #ComboBox and the option &#8212; don’t.&#160; If you look at my example above, that code will only work for options not in optgroup nodes.</p>
<h2>3. Find out when the select value changed</h2>
<p>This is also rather easy with JQuery.</p>
<div style="border-bottom: gray 1px solid; border-left: gray 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: gray 1px solid; cursor: text; border-right: gray 1px solid; padding-top: 4px">
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   1:</span> $(<span style="color: #006080">&quot;#ComboBox&quot;</span>).change(function() { <span style="color: #008000">/* do something here */</span> });</pre>
</p></div>
</div>
<h2>4. Programmatically set the selected item.</h2>
<div style="border-bottom: gray 1px solid; border-left: gray 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: gray 1px solid; cursor: text; border-right: gray 1px solid; padding-top: 4px">
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   1:</span> $(<span style="color: #006080">&quot;#ComboBox&quot;</span>).val(2);</pre>
</p></div>
</div>
<h2>5. Modify the list.</h2>
<p>Modifying a select element is not fundamentally different than modifying any other element in the dom, but there are a few basics here to keep in mind. Mainly: try to avoid using the dom directly.&#160; Create html strings instead.</p>
<p>Clear the list:&#160;&#160; $(“#ComboBox”).html(“”);<br />
  <br />Add to the list: $(“&lt;option value=’9’&gt;Value 9&lt;/option&gt;”).appendTo(“#ComboBox”);</p>
<p>Simple as that.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ElegantCode?a=FI_rEvCHwYU:q46cZUQIdGI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ElegantCode?i=FI_rEvCHwYU:q46cZUQIdGI:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=FI_rEvCHwYU:q46cZUQIdGI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=FI_rEvCHwYU:q46cZUQIdGI:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=FI_rEvCHwYU:q46cZUQIdGI:XAVGb8Xj5zA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=XAVGb8Xj5zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=FI_rEvCHwYU:q46cZUQIdGI:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=G79ilh31hkQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ElegantCode/~4/FI_rEvCHwYU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/07/01/jquery-playing-with-select-dropdownlistcombobox/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PUTting the Couch(DB) in Your Living Room</title>
		<link>http://elegantcode.com/2009/07/01/putting-the-couchdb-in-your-living-room/</link>
		<comments>http://elegantcode.com/2009/07/01/putting-the-couchdb-in-your-living-room/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 22:04:29 +0000</pubDate>
		<dc:creator>Jan Van Ryswyck</dc:creator>
		
		<category><![CDATA[CouchDB]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/07/01/putting-the-couchdb-in-your-living-room/</guid>
		<description><![CDATA[In my previous posts, I provided a shallow introduction to CouchDB and how to get it installed on a Linux box. Here are the links to these posts:

Relaxing on the Couch(DB)
Installing the Couch(DB)

Now, for this post I want to talk about how to create and manage documents. As I already mentioned in my introductory blog [...]]]></description>
			<content:encoded><![CDATA[<p>In my previous posts, I provided a shallow introduction to <a href="http://couchdb.apache.org/" target="_blank">CouchDB</a> and how to get it installed on a Linux box. Here are the links to these posts:</p>
<ol>
<li><a href="http://elegantcode.com/2009/05/23/relaxing-on-the-couchdb/" target="_blank">Relaxing on the Couch(DB)</a>
<li><a href="http://elegantcode.com/2009/05/30/installing-the-couchdb/" target="_blank">Installing the Couch(DB)</a></li>
</ol>
<p>Now, for this post I want to talk about how to create and manage documents. As I already mentioned in my introductory blog post, CouchDB is accessible through a RESTful HTTP/JSON API. This means that documents are stored as JSON objects. Let me show you an example of how to store a document in CouchDB.&nbsp; </p>
<p>Suppose we have a class named <em>Document</em> (how creative of me). A <em>Document </em>has a title, an author and a collection of <em>Tag</em> objects. A <em>Tag</em> is a value object that has a name.</p>
<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> Document
{
    <span class="kwrd">private</span> <span class="kwrd">readonly</span> ISet&lt;Tag&gt; _tags;

    <span class="kwrd">public</span> String Author { get; }
    <span class="kwrd">public</span> String Title { get; }
    <span class="kwrd">public</span> Guid Id { get; }
    <span class="kwrd">public</span> String Version { get; }

    <span class="kwrd">public</span> IEnumerable&lt;Tag&gt; Tags
    {
        get { <span class="kwrd">return</span> _tags; }
    }
}

<span class="kwrd">public</span> <span class="kwrd">class</span> Tag : ValueObject&lt;Tag&gt;
{
    <span class="kwrd">public</span> String Name { get; <span class="kwrd">private</span> set; }

    <span class="kwrd">public</span> Tag(String name)
    {
        Name = name;
        RegisterProperty(<span class="kwrd">value</span> =&gt; <span class="kwrd">value</span>.Name);
    }
} </pre>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
<p>Nothing fancy so far. Now in order to save an instance of this class, we have to serialize it to its JSON representation. I&#8217;ve been using <a href="http://www.codeplex.com/Json" target="_blank">Json.NET</a> for this purpose, but you might as well use the <a href="http://msdn.microsoft.com/en-us/library/system.web.script.serialization.javascriptserializer.aspx" target="_blank">JavaScriptSerializer</a> class from the .NET framework.</p>
<p>Now, in order to save a document, we make use of the PUT HTTP method. This implies that we have to provide our own document identifier. We have to initialize the <em>Id</em> property with a new GUID for a new <em>Document</em>. We could also make use the POST HTTP method. This way you don&#8217;t have to specify your own document identifier and let CouchDB generate one for you when the document is initially stored. But this is discouraged because proxies and other network intermediaries are able to resend POST requests resulting in duplicate documents.</p>
<p>Creating a new document in CouchDB using the PUT method takes the following general form:</p>
<blockquote>
<p><a href="http://myhost:5984/my_database/my_id">http://myhost:5984/my_database/my_id</a></p>
</blockquote>
<p>So for our example, sending the following request:</p>
<pre class="csharpcode">PUT /documentstore/80c8675d-2015-45f5-a3c7-098226e15ce3 HTTP/1.1
Content-Type: application/json
Host: 146.135.16.100:5984
Content-Length: 1215256
Expect: 100-<span class="kwrd">continue</span>

{
<span class="str">"Author"</span>:<span class="str">"Stephen Hawking"</span>,
<span class="str">"Title"</span>:<span class="str">"The Universe in a Nutshell"</span>,
<span class="str">"Tags"</span>:[{<span class="str">"Name"</span>:<span class="str">"Physics"</span>},{<span class="str">"Name"</span>:<span class="str">"Universe"</span>}]
}</pre>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
<p>makes CouchDB return the following response:</p>
<pre class="csharpcode">{
<span class="str">"ok"</span>:<span class="kwrd">true</span>,
<span class="str">"id"</span>:<span class="str">"80c8675d-2015-45f5-a3c7-098226e15ce3"</span>,
<span class="str">"rev"</span>:<span class="str">"1-1437623276"</span>
}</pre>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
<p>You probably figured out by now that this response means that the document has successfully been stored by CouchDB. Notice that it also returns a revision number that was generated upon creating the document in the database. This is important when we try to save changes to the document later on. </p>
<p>If you&#8217;re as suspicious as I am, you probably want to verify whether CouchDB&nbsp; correctly stored the document we&#8217;ve provided. You can do this using <a href="http://couchdb.apache.org/screenshots.html" target="_blank">Futon</a>, the web-based user interface of CouchDB. You can access Futon through the following URL:</p>
<blockquote>
<p><a href="http://myhost:5984/_utils">http://myhost:5984/_utils</a></p>
</blockquote>
<p>Say that we already want to make some changes to the document we just created. Lets add a new tag to the document named <em>&#8216;Space&#8217;</em>. We add a new <em>Tag</em> object to the instance of our <em>Document, </em>we serialize it back to its JSON representation and send the following request, asking CouchDB to save the changes:</p>
<pre class="csharpcode">PUT /documentstore/80c8675d-2015-45f5-a3c7-098226e15ce3 HTTP/1.1
Content-Type: application/json
Host: 146.135.16.100:5984
Content-Length: 1705803
Expect: 100-<span class="kwrd">continue</span>

{
<span class="str">"_rev"</span>:<span class="str">"1-1437623276"</span>,
<span class="str">"Author"</span>:<span class="str">"Stephen Hawking"</span>,
<span class="str">"Title"</span>:<span class="str">"The Universe in a Nutshell"</span>,
<span class="str">"Tags"</span>:[{<span class="str">"Name"</span>:<span class="str">"Physics"</span>},{<span class="str">"Name"</span>:<span class="str">"Universe"</span>},{<span class="str"><font color="#ff0000">"Name"</font></span>:<span class="str"><font color="#ff0000">"Space"</font></span>}]
}</pre>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
<p>Notice that we are using the PUT method again, but now we also provided the revision number we got back from our first response when we initially created the document. Also notice that we are sending the complete document again, but now with the extra tag. </p>
<p>CouchDB returns the following response that contains a new revision number for the document:</p>
<pre class="csharpcode">{
<span class="str">"ok"</span>:<span class="kwrd">true</span>,
<span class="str">"id"</span>:<span class="str">"80c8675d-2015-45f5-a3c7-098226e15ce3"</span>,
<span class="str">"rev"</span>:<span class="str">"2-3213552600"</span>
}</pre>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
<p>Again, you can use Futon to verify if CouchDB stored a new version of the document. For my next post on CouchDB, I will talk about how retrieve a document from CouchDB.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ElegantCode?a=Z0d8brONX3Y:6oE7zNzzRoc:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ElegantCode?i=Z0d8brONX3Y:6oE7zNzzRoc:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=Z0d8brONX3Y:6oE7zNzzRoc:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=Z0d8brONX3Y:6oE7zNzzRoc:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=Z0d8brONX3Y:6oE7zNzzRoc:XAVGb8Xj5zA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=XAVGb8Xj5zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=Z0d8brONX3Y:6oE7zNzzRoc:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=G79ilh31hkQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ElegantCode/~4/Z0d8brONX3Y" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/07/01/putting-the-couchdb-in-your-living-room/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Vault and CruiseControl.NET Error: Working Folder State Problem</title>
		<link>http://elegantcode.com/2009/07/01/vault-and-cruisecontrolnet-error-working-folder-state-problem/</link>
		<comments>http://elegantcode.com/2009/07/01/vault-and-cruisecontrolnet-error-working-folder-state-problem/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 16:23:54 +0000</pubDate>
		<dc:creator>Tony Rasa</dc:creator>
		
		<category><![CDATA[Source Control]]></category>

		<category><![CDATA[CruiseControl.NET]]></category>

		<category><![CDATA[Vault]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/07/01/vault-and-cruisecontrolnet-error-working-folder-state-problem/</guid>
		<description><![CDATA[This is one of those problems that teaches humility.&#160; I’m posting this here because the solution is a) trivially obvious, any fool could see it and b) I completely overlooked the obvious solution and maybe a google “hint” would have saved me some time.
At Blackfin, we use SourceGear Vault and CruiseControl.net. (We’re moving to Subversion [...]]]></description>
			<content:encoded><![CDATA[<p>This is one of those problems that teaches humility.&#160; I’m posting this here because the solution is a) trivially obvious, any fool could see it and b) I completely overlooked the obvious solution and maybe a google “hint” would have saved me some time.</p>
<p>At <a href="http://www.blackfin.com" target="_blank">Blackfin</a>, we use SourceGear Vault and CruiseControl.net. (We’re moving to Subversion and TeamCity, but that’s a different post.)&#160; One of our projects on one of our CC.NET servers was failing with this exception:</p>
<p><font face="Courier New">“The working folder state information for C:\CruiseControl.NET\Build\MyProject\working is incompatible with this version of Vault.&#160; Please choose a different working folder path.&#160; The specific compatibility exception was: Could not detect the file type in the supplied stream.”</font></p>
<p>Vault likes to litter your system with lots of little state files, and on rare occasion these files get corrupted.&#160; To fix, you just <a href="http://support.sourcegear.com/viewtopic.php?t=6" target="_blank">delete the local cache directories</a>, re-get repositories, and you’re on your way again.&#160; Piece of cake.&#160; </p>
<p>I deleted all the cache files on this server, from C:\Documents and Settings\{username}\Local Settings\Application Data\SourceGear.&#160; To be thorough, I delete all the cache files I can find for all users.&#160; BUT, the exceptions continue.</p>
<p>Thinking to myself, “well obviously I’ve not deleted the right directory” I run a search for all directories named “Vault_1”, which turns up…nothing.</p>
<p>What follows next is a bunch of flailing about, checking for cc.net bugs, and to sum up: grasping at straws.&#160; What *should* have happened is that I re-read the exception and think carefully about what causes it: a corrupted state file that I haven’t deleted yet.</p>
<p>I run CruiseControl.Net as a service, under the local NetworkService account.&#160; Therefore, I [failed to] reason, the cache files must be in C:\Documents and Settings\NetworkService\Local Settings\Application Data\SourceGear.&#160; But I couldn’t find this directory on the system.&#160; Except that the NetworkService directory is marked as a “protected Operating System file”.&#160; Remember that Folder option “Hide protected operating system files (recommended)” that you always switch off and ignore the dialog box that pops up?&#160; It was still checked…</p>
<p>Uncheck that dumb setting, go into the directory, delete the cache, and now the build works again.&#160; </p>
<p>Lesson: sometimes exceptions tell you exactly what’s wrong.&#160; Don’t be so quick to search for exotic solutions when the obvious one is staring you in the face.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ElegantCode?a=VqCikzN1lLs:u2hVokvN-2k:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ElegantCode?i=VqCikzN1lLs:u2hVokvN-2k:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=VqCikzN1lLs:u2hVokvN-2k:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=VqCikzN1lLs:u2hVokvN-2k:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=VqCikzN1lLs:u2hVokvN-2k:XAVGb8Xj5zA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=XAVGb8Xj5zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=VqCikzN1lLs:u2hVokvN-2k:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=G79ilh31hkQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ElegantCode/~4/VqCikzN1lLs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/07/01/vault-and-cruisecontrolnet-error-working-folder-state-problem/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The Split Personality of the Tester/Developer</title>
		<link>http://elegantcode.com/2009/06/30/the-split-personality-of-the-testerdeveloper/</link>
		<comments>http://elegantcode.com/2009/06/30/the-split-personality-of-the-testerdeveloper/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 03:39:27 +0000</pubDate>
		<dc:creator>Alex Mueller</dc:creator>
		
		<category><![CDATA[Esoterica]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/06/30/the-split-personality-of-the-testerdeveloper/</guid>
		<description><![CDATA[From the site, http://www.softwareqatest.com/qatfaq2.html, I came across this statement. There are many forms of software testing. What I am discussing herein is related to white-box testing, automation and framework development, performance, and security testing
What makes a good Software Test engineer? 

“A good test engineer has a &#8216;test to break&#8217; attitude, an ability to take the [...]]]></description>
			<content:encoded><![CDATA[<p>From the site, <a href="http://www.softwareqatest.com/qatfaq2.html">http://www.softwareqatest.com/qatfaq2.html</a>, I came across this statement. There are many forms of software testing. What I am discussing herein is related to white-box testing, automation and framework development, performance, and security testing</p>
<blockquote><p>What makes a good Software Test engineer? </p>
</blockquote>
<blockquote><p>“A good test engineer has a &#8216;test to break&#8217; attitude, an ability to take the point of view of the customer, a strong desire for quality, and an attention to detail. Tact and diplomacy are useful in maintaining a cooperative relationship with developers, and an ability to communicate with both technical (developers) and non-technical (customers, management) people is useful. <strong><em>Previous software development experience can be helpful as it provides a deeper understanding of the software development process, gives the tester an appreciation for the developers&#8217; point of view, and reduce the learning curve in automated test tool programming.</em></strong> Judgment skills are needed to assess high-risk or critical areas of an application on which to focus testing efforts when time is limited.”</p>
</blockquote>
<p>In my opinion, more emphasis should be placed on the statement italicized above. Taking it a step further, I would say a developer with previous development knowledge of the product under test is even more valuable. Obviously domain knowledge is what increases this value. From previous experiences with organizations, the development skills of the tester are often largely ignored. </p>
<p>“Writing code? That’s what our developers do, not our testers.”</p>
<p>If we are not placing a greater emphasis on the development skills of the tester, we are missing opportunities to fully test the product. Testers with a development background are more familiar with the developer&#8217;s perspective. They know the tricks developers do when writing code, they know their shortcuts and tendencies. These testers can also provide developers with insight into defensive coding, adding hooks to make automation easier, securing the product from attacks, ect. </p>
<p>I would argue the inverse is true as well, that having previous testing experience of the product would add value to the transition of a tester into development. A developer with a testing background should improve the testability and security of the product, because they, too, understand the importance and impact of test.</p>
<p>To me, test and development should be shared responsibilities. If a developer is out sick, on vacation, or the team needs a resource, a tester should be able to fill in, developing product code. If a tester is needed for similar reasons, a developer should be able to switch gears and fulfill that need as well. Neither should be more exciting nor glamorous. The organization should respect both disciplines equally. Testing is the last line of defense.&#160; </p>
<p>The software engineer should have two personae, constructive and destructive. Perhaps this is similar to Dr. Jekyll and Mr. Hyde, where we replace the “evil” in Mr. Hyde with “destructive product testing.” </p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ElegantCode?a=6fz2e6Xrpvw:Y9WPRA82WW4:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ElegantCode?i=6fz2e6Xrpvw:Y9WPRA82WW4:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=6fz2e6Xrpvw:Y9WPRA82WW4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=6fz2e6Xrpvw:Y9WPRA82WW4:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=6fz2e6Xrpvw:Y9WPRA82WW4:XAVGb8Xj5zA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=XAVGb8Xj5zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=6fz2e6Xrpvw:Y9WPRA82WW4:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=G79ilh31hkQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ElegantCode/~4/6fz2e6Xrpvw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/06/30/the-split-personality-of-the-testerdeveloper/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Elegant Code Project Structure Purse Fight</title>
		<link>http://elegantcode.com/2009/06/28/elegant-code-project-structure-purse-fight/</link>
		<comments>http://elegantcode.com/2009/06/28/elegant-code-project-structure-purse-fight/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 03:57:26 +0000</pubDate>
		<dc:creator>Chris Brandsma</dc:creator>
		
		<category><![CDATA[Esoterica]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/06/28/elegant-code-project-structure-purse-fight/</guid>
		<description><![CDATA[We here at Elegant Code have our own little list group that we participate in.&#160; It is a nice place to ask questions to some fairly advanced individuals.&#160; Today, David Starr posed the question project structures.&#160; He said this could be a religious debate, but I don’t believe anyone took this up as a matter [...]]]></description>
			<content:encoded><![CDATA[<p>We here at Elegant Code have our own little list group that we participate in.&#160; It is a nice place to ask questions to some fairly advanced individuals.&#160; Today, David Starr posed the question project structures.&#160; He said this could be a religious debate, but I don’t believe anyone took this up as a matter for dogma.&#160; The cool part was we actually got a good chunk of the Elegant Code group to comment on this.&#160; That is when you know you have a good topic.</p>
<p>But there are a lot of opinions here and a lot of good discussion. Anyway, you can follow the thread. Note: I did a little bit of editing because Tony Rasa doesn’t like capital letters.</p>
<h3>David Starr</h3>
<p>Here comes a religious discussion.</p>
<p>You are building a new enterprise app. Let&#8217;s use my RecipeBox example. It is an MVC app.</p>
<p>What do you think about this project structure? $ = A Visual Studio Project</p>
<p>$RecipeBox.Core   <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; \Services    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; \Assemblers    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; \Contracts (or Interfaces) for entities and repositories    <br />$RecipeBox.Domain    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; \Entities    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; \Repositories    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; \Validators    <br />$RecipeBox.Data    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; \DTOs    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; \Repositories    <br />$RecipeBox.Web    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; The MVC app</p>
<p>Thoughts?</p>
<h3>Tony Rasa</h3>
<p>I prefer having fewer projects and splitting things out after figuring out what the need is - so, having a .Core and .Web (along with .Tests), but then Core contains namespaces similar to what you&#8217;ve described.&#160; But that&#8217;s just me.</p>
<p>There are projects where we&#8217;ve split things out by project to enforce design rules, (maybe .Web should never directly reference .Data for example) in cases where we don&#8217;t trust the developers, or there is a &#8216;control issue&#8217; with the project team&#8230;&#160; I prefer personal responsibility and reviews myself, but I suppose you&#8217;ll never get anywhere trusting to the good nature of people..</p>
<h3>Jason Grundy</h3>
<p>I agree with Tony - Web, Core and Test. Within these, especially as the project grows, I am starting to use namespaces as DDD modules to subdivide the app into functional areas. Nothing worse than having 250 entities in a single namsespace!</p>
<h3>Scott Nichols</h3>
<p>I actually like having multiple assemblies (like you laid out) for an &quot;enterprise app&quot;. Granted &quot;enterprise app&quot; can mean a lot of things to a lot of people but I&#8217;ll go with the following assumptions.   <br /> - Used by a business/company/group, more likely in an intranet setting.    <br /> - The app components will be living in physical and logical tiers owned/managed by users.    <br /> - There is a possibility that other types of clients (windows, services, reporting SSRS, etc) may need to access/integrate with the apps data.    <br /> - etc, etc..    <br />With some of these assumptions in mind I have found (my opinion) that having multiple assemblies will give you a greater degree of separation of concern, reusability between tiers and clients, and better maintainability if any of    <br />these assemblies get reused by something other than the MVC app.&#160; The Application Architecture Guide <a href="http://www.codeplex.com/AppArch">http://www.codeplex.com/AppArch</a> outlines these practices as well. In fact, when I look at your example I do not think you have gone far enough. For instance&#8230;    <br />@ = A Solution    <br /># = A VS Solution Folder (and namespace)</p>
<p>$ = A Visual Studio Project   <br />@RecipeBox    <br /> #RecipeBox.Core    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $\Services    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $\Assemblers    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $\Contracts (or Interfaces) for entities and repositories</p>
<p>Why would I do this?   <br />If your Contracts and Services are in their own assemblies you can reuse them independently of each other which would be very important if you ever wanted to create a WCF service for this app (one example). Maybe down the    <br />road you wanted to have two different implementations of the service class but they both still implement the same interface.&#160; In any case, it would work just fine by leaving all these classes in a single RecipeBox.Core DLL    <br />as you listed them.&#160; Your DLL would just be a bit bigger than it needed to be if you just wanted to share your interfaces for example. Personal preference, I&#8217;ve always liked my interfaces (contracts) in their own    <br />assembly.</p>
<p>The downside to all of this is that the more assemblies you add the more management is involved of your entire solution (keeping track of everything).&#160; That was the main reason Rocky Lhotka decided to roll all the CSLA assemblies into a single DLL, much easier to distribute.&#160; That move made sense to me though, because to use the CSLA framework you had to reference just about every assembly anyway.&#160; That is not necessarily the case with a distributed enterprise scenario, you pick and choose more discriminately based on what you are trying to accomplish.</p>
<p>I have also found one other major factor that helps determine how you distribute/group your assemblies.&#160; The structure of your IT organization. Really large distributed teams tend to break things down much more   <br />granularly, more assemblies.&#160; Smaller more centralized teams tend to like less assembles.&#160; This is just an observation I&#8217;ve noticed over the years.    <br />My two cents</p>
<h3>David Starr</h3>
<p>Yeah, I am, thinking in similar terms to exactly what you are saying. The other thing I like about separation via projects is a real enforcement of programming through interfaces. This is forced because to not do so would create circular project references.   <br />Thanks, guys.</p>
<h3>Chris Brandsma</h3>
<p>I agree with Tony and Jason here.&#160; But I don&#8217;t think any of us believe this is a major fighting point.</p>
<p>With the extra projects you get forced separation.&#160; Which is nice for junior devs (or devs you want to put handcuffs on).&#160; But a bad dev will figure out a way to screw up almost anything.</p>
<p>With fewer projects and namespaces you have a virtual separation.&#160; But the solution loads quicker.&#160; </p>
<p>I like solutions that load faster.</p>
<h3>Jason Grundy</h3>
<p>Some more observations:</p>
<p>Jeremy Miller would say that an assembly is a unit of deployment.</p>
<p>With multiple projects your compile time will be significantly higher.</p>
<p>When you have multiple pieces that need to integrate for a specific purpose then I don&#8217;t think that a single VS solution is necessarily the best solution anyway.</p>
<h3>Darrel Carver</h3>
<p>One last point on having more projects and assemblies.&#160; You can separate the work among your project team.&#160;&#160; That usually means people are working on more thing independently (interfaces can help enforce that).&#160; It also means less conflicts when you check in the work to source code control.</p>
<h3>David Starr</h3>
<p>That&#8217;s what I am doing here.   <br />Physical separation for different teams with a &quot;meet in the middle via contract&quot; agreement.</p>
<h3></h3>
<h3>Jarod Ferguson</h3>
<p>some thoughts&#8230;.</p>
<p>Just curious, but what are the units of deployment, how many app domains? ( are the services WCF? asking because of the word *contract* in there)</p>
<p>This is all relevant to team size, but is sounds like you are heading in the direction of a larger org with many teams?</p>
<p>Its it ideal for team to be separated by modules, vertical slices. Meeting in the middle with a wcf contract may make your teams horizontal. </p>
<p>Why are there repositories at the Data layer &amp; Domain layer? </p>
<p>What is the Data layer? I would make this DLL your contract/interface dll with all your service interfaces AND Dtos, this way the client only has to reference this one Dll to get the service interface &amp; DTO.</p>
<p>As with Jason, I would move to a more vertical &#8216;business minded&#8217; aka, DDD, namespacing structure as soon as the application architecture would let you (after .Domain in this example). It can get mind numbing to work in all those layers, when what you are trying to do is all related.</p>
<p>E.g</p>
<p>$RecipeBox.Domain   <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; \Entities\Customer.cs    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; \Repositories\CustomerRepository.cs    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; \Validators\CustomerValidator.cs    <br />$RecipeBox.Domain    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; \Customers    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Customer.cs    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; CustomerRepository.cs    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; CustomerValidator.cs</p>
<p>&#160;</p>
<h3>Scott Nichols</h3>
<p>While we are on the topic, the physical folder structure is very important to get nailed down as well, otherwise your source control implementation/maintenance can get a bit ugly too.&#160;&#160; David, I imagine you being the TFS guy would be all over this.&#160; My group put together this basic outline on how to structure the source control folders (hopefully my attachment comes through), any thoughts?</p>
<p>It is basically a variation of what Microsoft published at <a href="http://msdn.microsoft.com/en-us/library/bb668992.aspx">http://msdn.microsoft.com/en-us/library/bb668992.aspx</a>. It mentions TFS but could obviously be applied to any system.</p>
<h3></h3>
<h3>Tony Rasa</h3>
<p>The &quot;so we can switch to Technology X later, if we want&quot; argument always sets off my YAGNI alarm.&#160; If you know that you&#8217;re going to need the enterprise-wide solution, supporting multiple front ends etc, then yeah, you gotta go with the added complexity.&#160; Scott&#8217;s one of the guys who has those extra requirements, too often i hear it applied to the   <br />&quot;selling junk online / customer management&quot; website.&#160; I think its easier to scale to that as a need is identified (ideally towards the beginning but sometimes you don&#8217;t get that luxury), otherwise you&#8217;re adding complexity without the payoff&#8230;hey, haven&#8217;t we had this discussion before <img src='http://elegantcode.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Agree on the source layout issue as well, pick a structure that works for you and run with it.. don&#8217;t let the jr devs mess up the source tree!&#160; better yet, train the jr devs so they know better&#8230;</p>
<h3></h3>
<h3>Chris Brandsma</h3>
<p>Side note: this is a case where I&#8217;m not as worried about the junior devs.&#160; Mid-levels or or mis-promoted seniors will cause more damage.</p>
<h3>Scott Nichols</h3>
<p>I am a huge advocate of KIS (keep it simple) and would not disagree with anyone who is trying to keep the number of assemblies to as few as absolutely needed.&#160; I imagine given this crowd that with David’s MVC app if developed by any of us it would be layered and broken-down into a very nice API following the SOLID principles.&#160; However, given a few other pieces of key information (not provided by David) the same code would be broken-down and packaged differently.&#160;&#160;&#160;&#160; </p>
<p>David was pretty vague on the requirements (purposely so I bet).&#160; I’ll pick on Chris for a bit (he is man enough to handle it :-)&#160; His typical clients (correct me if I am wrong) are not the big enterprise guys that are going to have large distributed teams or infrastructure requirements that require lots of end-points that various systems will need to touch or integrate with.&#160;&#160; He is going into a company to build application X as fast and under budget as possible in his own little sand box so to speak.&#160;&#160; If I were in Chris’s shoes I would build this fictitious MVC app as single tired as possible.&#160; Ok being me, I would still probably have at least three assembles.&#160; Anything to deal or relate to data into a DAL assembly, all service type code especially if messaging based like WCF into a Services assembly, and all the remaining MVC code into a single app assembly.&#160;&#160; Although, if it were all in one assembly I would not lose any sleep over it , Chris writes nice code, I am sure it could be repackaged later if needed quite easily.</p>
<p>My typical world is a bit different.&#160; I may get the same request to build an MVC app but there would be added requirements.&#160; This app would probably need to get data from a few systems and then provide it’s data to several other systems (highly integrated/distributed).&#160; Multi clients in some form would be in the mix and an architecture that could easily scale the various tiers as the enterprise demands grow.&#160;&#160; With that, you tend to break things down a bit more so you can reuse your code as I describe in my earlier e-mail.&#160;&#160; You still need to keep your head about you though, and not go crazy on your physical abstractions (assembly madness) .&#160; You do it where it makes sense to meet a business requirement.&#160; Start simple (KIS) and repackage (multiple assemblies) as needed to reuse various code bases to fulfill your architecture needs.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ElegantCode?a=6EpzQPY05bU:k8HGzREiW3k:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ElegantCode?i=6EpzQPY05bU:k8HGzREiW3k:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=6EpzQPY05bU:k8HGzREiW3k:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=6EpzQPY05bU:k8HGzREiW3k:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=6EpzQPY05bU:k8HGzREiW3k:XAVGb8Xj5zA"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=XAVGb8Xj5zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ElegantCode?a=6EpzQPY05bU:k8HGzREiW3k:G79ilh31hkQ"><img src="http://feeds.feedburner.com/~ff/ElegantCode?d=G79ilh31hkQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ElegantCode/~4/6EpzQPY05bU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/06/28/elegant-code-project-structure-purse-fight/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
