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

<channel>
	<title>dasz.at - Benutzbare Technologie &#187; StackOverflow</title>
	<atom:link href="http://dasz.at/index.php/category/tech/stackoverflow/feed/" rel="self" type="application/rss+xml" />
	<link>http://dasz.at</link>
	<description>Benutzbare Technologie</description>
	<lastBuildDate>Wed, 07 Jul 2010 06:54:18 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>AppDomainUnloadedException with NUnit, a ServiceHost and several other technologies</title>
		<link>http://dasz.at/index.php/2010/01/appdomainunloadedexception-when-using-nunit-with-servicehost-and-similar-technologies/</link>
		<comments>http://dasz.at/index.php/2010/01/appdomainunloadedexception-when-using-nunit-with-servicehost-and-similar-technologies/#comments</comments>
		<pubDate>Mon, 18 Jan 2010 16:03:01 +0000</pubDate>
		<dc:creator>David Schmitt</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[StackOverflow]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://dasz.at/index.php/2010/01/appdomainunloadedexception-when-using-nunit-with-servicehost-and-similar-technologies/</guid>
		<description><![CDATA[All tests ok, but still a NUnit failure?
Seeing unexplicable &#8220;System.AppDomainUnloadedException: Attempted to access an unloaded AppDomain.&#8221; errors?
You might be a victim of nunit&#8217;s bug #423611.
See also here, here and here.
A typical error message looks like this:

Unhandled exceptions:
1)  : System.AppDomainUnloadedException: Attempted to access an unloaded AppDomain.
I&#8217;ve uploaded a minimal solution exhibiting the problem to the [...]]]></description>
			<content:encoded><![CDATA[<p>All tests ok, but still a NUnit failure?</p>
<p>Seeing unexplicable &#8220;System.AppDomainUnloadedException: Attempted to access an unloaded AppDomain.&#8221; errors?</p>
<p>You might be a victim of <a href="https://bugs.launchpad.net/nunitv2/+bug/423611">nunit&#8217;s bug #423611</a>.</p>
<p>See also <a href="http://stackoverflow.com/questions/561402/cassini-webserver-webdev-nunit-and-appdomainunloadedexception">here</a>, <a href="http://haacked.com/archive/2006/12/12/Using_WebServer.WebDev_For_Unit_Tests.aspx">here</a> and <a href="http://blogs.dovetailsoftware.com/blogs/kmiller/archive/2007/11/07/unit-testing-a-web-service.aspx">here</a>.</p>
<p>A typical error message looks like this:</p>
<blockquote><p>
Unhandled exceptions:<br />
1)  : System.AppDomainUnloadedException: Attempted to access an unloaded AppDomain.</p></blockquote>
<p>I&#8217;ve uploaded a minimal solution exhibiting the problem to the bugreport and I hope that&#8217;ll help clearing the issue up.</p>
]]></content:encoded>
			<wfw:commentRss>http://dasz.at/index.php/2010/01/appdomainunloadedexception-when-using-nunit-with-servicehost-and-similar-technologies/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Attaching Events to ListViewItems in WPF</title>
		<link>http://dasz.at/index.php/2009/06/attaching-events-to-listviewitems-in-wpf/</link>
		<comments>http://dasz.at/index.php/2009/06/attaching-events-to-listviewitems-in-wpf/#comments</comments>
		<pubDate>Fri, 05 Jun 2009 12:13:35 +0000</pubDate>
		<dc:creator>David Schmitt</dc:creator>
				<category><![CDATA[StackOverflow]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://dasz.at/index.php/2009/06/attaching-events-to-listviewitems-in-wpf/</guid>
		<description><![CDATA[I was looking for a way to attach a MouseDoubleClickHandler to the implicitly generated ListViewItems in a databound control:


&#60;ListView ItemsSource=&#34;{Binding Instances}&#34; /&#62;

For some strange reason all the mouse events seem to be directly routed instead of bubbling like other input events. Only some magic of the framework causes them to be raised for every hit [...]]]></description>
			<content:encoded><![CDATA[<p>I was looking for a way to attach a <a href="http://msdn.microsoft.com/en-us/library/system.windows.input.mousebuttoneventhandler.aspx">MouseDoubleClickHandler</a> to the implicitly generated ListViewItems in a databound control:</p>
<pre class="brush: xml; ">

&lt;ListView ItemsSource=&quot;{Binding Instances}&quot; /&gt;
</pre>
<p>For some strange reason all the mouse events seem to be directly routed instead of bubbling like other input events. Only some magic of the framework causes them to be raised for every hit control. This causes the <code>sender</code> to be totally worthless, since it is always the &#8220;current&#8221; object.</p>
<p><span id="more-84"></span> </p>
<p>Uncle Google just brought up a useless and wrong answer on the &#8220;site with a hyphen.&#8221; But after some fiddling I found the answer: just use an <code>EventSetter</code> to set the handler on all items:</p>
<pre class="brush: xml; ">

&lt;ListView ItemsSource=&quot;{Binding Instances}&quot; &gt;
    &lt;ListView.Resources&gt;
        &lt;Style TargetType=&quot;ListViewItem&quot;&gt;
            &lt;EventSetter Event=&quot;MouseDoubleClick&quot;
                Handler=&quot;OnDoubleClick&quot; /&gt;
        &lt;/Style&gt;
    &lt;/ListView.Resources&gt;
&lt;/ListView&gt;
</pre>
<p>Then I wanted to post the question and answer to <a href="http://stackoverflow.com">stackoverflow</a> so others can profit from it too. It turns out that this is an already solved problem: <a href="http://stackoverflow.com/questions/728205/wpf-listview-attaching-a-double-click-on-an-item-event">WPF ListView: Attaching a double-click (on an item) event</a>. Furthermore, both this page and the linked thread on the MSDN Forum were also available on the google results. Meh.</p>
]]></content:encoded>
			<wfw:commentRss>http://dasz.at/index.php/2009/06/attaching-events-to-listviewitems-in-wpf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C++ templates for Fun and Profit</title>
		<link>http://dasz.at/index.php/2009/04/c-templates-for-fun-and-profit/</link>
		<comments>http://dasz.at/index.php/2009/04/c-templates-for-fun-and-profit/#comments</comments>
		<pubDate>Sun, 26 Apr 2009 10:36:20 +0000</pubDate>
		<dc:creator>David Schmitt</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Reviews]]></category>
		<category><![CDATA[StackOverflow]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://dasz.at/index.php/2009/04/c-templates-for-fun-and-profit/</guid>
		<description><![CDATA[Wijaa asks on stackoverflow: What’s the most brilliant use of templates you’ve ever encountered?
Reading the linked articles gave me much joy. Here are some highlights:


In FOREACH Redux, Eric Niebler describes his long path to the BOOST_FOREACH macro, which emulates C#&#8217;s foreach statement in C++. At the core, it all revolves around using the conditional operator [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://stackoverflow.com/users/94526/wijaa">Wijaa</a> asks on <a href="http://stackoverflow.com/">stackoverflow</a>: <a href="http://stackoverflow.com/questions/790494/whats-the-most-brilliant-use-of-templates-youve-ever-encountered">What’s the most brilliant use of templates you’ve ever encountered?</a></p>
<p>Reading the linked articles gave me much joy. Here are some highlights:<br />
<span id="more-81"></span></p>
<ul>
<li>In <a href="http://www.artima.com/cppsource/foreach.html">FOREACH Redux</a>, Eric Niebler describes his long path to the <code>BOOST_FOREACH</code> macro, which emulates C#&#8217;s <code>foreach</code> statement in C++. At the core, it all revolves around using the conditional operator <a href="http://en.wikipedia.org/wiki/Conditional_operator#C.2B.2B"><code>?:</code></a> with templates to work the compilers type inference engine:
<pre class="brush: c++; ">

struct rvalue_probe
{
   template&lt; class R &gt; operator R ()
   {
        throw &quot;rvalue&quot;;
   }
   template&lt; class L &gt; operator L &amp;amp; () const
   {
        throw &quot;lvalue&quot;;
   }
};

#define RVALUE_TEST(container) \
   try { ( true ? rvalue_probe() : (container) ); } \
   catch( char const * result ) { cout &lt;&lt;result &lt;&lt; &#039;\n&#039;; }
</pre>
<p>This snippet for example uses the overload resolution rules to decide whether <code>container</code> is an rvalue or an lvalue, without evaluating it. For a detailed explanation, read <a href="http://www.artima.com/cppsource/foreach.html">the full article</a>.</li>
<li>The next link leads to <a href="http://spirit.sourceforge.net/distrib/spirit_1_8_5/libs/spirit/doc/quick_start.html">the Spirit parser generator&#8217;s quick start</a>. Except that Spirit is no parser generator like <a href="http://en.wikipedia.org/wiki/Yacc">yacc</a>. All rules are directly defined in C++. This one-liner calls <code>f</code> every time a real number is recognized. Multiple numbers are separated with comma.<br />
<code><br />
real_p[&#038;f] >> *(',' >> real_p[&#038;f])<br />
</code><br />
<code>real_p</code> is a parser for real numbers, <code>>></code> puts parsers into sequences and <code>*</code> is the <a href="http://en.wikipedia.org/wiki/Kleene_star">Kleene Star</a>. Read the <a href="http://spirit.sourceforge.net/distrib/spirit_1_8_5/libs/spirit/doc/quick_start.html">quick start</a> for an explanation how this all fits together.
</li>
</ul>
<p>So whatever you do, don&#8217;t say C++ didn&#8217;t make any progress.</p>
<p>Have fun and a nice Sunday!</p>
]]></content:encoded>
			<wfw:commentRss>http://dasz.at/index.php/2009/04/c-templates-for-fun-and-profit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.Net microbenchmarking</title>
		<link>http://dasz.at/index.php/2009/01/net-microbenchmarking/</link>
		<comments>http://dasz.at/index.php/2009/01/net-microbenchmarking/#comments</comments>
		<pubDate>Sat, 31 Jan 2009 17:05:41 +0000</pubDate>
		<dc:creator>David Schmitt</dc:creator>
				<category><![CDATA[Benchmarking]]></category>
		<category><![CDATA[Linq]]></category>
		<category><![CDATA[StackOverflow]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://dasz.at/index.php/2009/01/net-microbenchmarking/</guid>
		<description><![CDATA[In a recent discussion on StackOverflow about performance of arrays vs. lists and for vs. foreach, Jon Skeet created a little microbenchmarking framework and posted his detailed findings on his blog.
First, my local results of the benchmark. I compiled them as Release under VS 2008 SP1. Running without debugging on a Q6600@2.40GHz, .NET 3.5 SP1. [...]]]></description>
			<content:encoded><![CDATA[<p>In a recent discussion on <a href="http://stackoverflow.com/">StackOverflow</a> about performance of <a href="http://stackoverflow.com/questions/454916/performance-of-arrays-vs-lists">arrays vs. lists</a> and <a href="http://stackoverflow.com/questions/472191/c-for-vs-foreach">for vs. foreach</a>, <a href="http://stackoverflow.com/users/22656/jon-skeet">Jon Skeet</a> created a little microbenchmarking framework and posted <a href="http://msmvps.com/blogs/jon_skeet/archive/2009/01/29/for-vs-foreach-on-arrays-and-lists.aspx">his detailed findings on his blog</a>.</p>
<p>First, my local results of the benchmark. I compiled them as Release under VS 2008 SP1. Running without debugging on a Q6600@2.40GHz, .NET 3.5 SP1. They pretty exactly match Jon&#8217;s numbers so I won&#8217;t duplicate them here, but you can find them in the page&#8217;s source.</p>
<p><!--><br />
============ Doubles ============<br />
============ double[] ============<br />
For                1,00<br />
ForHoistLength     1,00<br />
ForEach            1,00<br />
IEnumerableForEach 8,28<br />
Enumerable.Sum     8,27</p>
<p>============ List<double> ============<br />
For                 2,00<br />
ForHoistLength      1,43<br />
ForEach             6,02<br />
IEnumerableForEach 14,03<br />
Enumerable.Sum     14,04</p>
<p>============ Ints ============<br />
============ int[] ============<br />
For                 1,00<br />
ForHoistLength      2,06<br />
ForEach             1,38<br />
IEnumerableForEach 15,46<br />
Enumerable.Sum     16,06</p>
<p>============ List<int> ============<br />
For                 2,84<br />
ForHoistLength      3,53<br />
ForEach             4,86<br />
IEnumerableForEach 26,33<br />
Enumerable.Sum     26,33</p>
<p><!--></p>
<p>Out of interest how the differences are when there is more to do in the loop&#8217;s body, I added a test suite that formatted the sum as string and appended it to a <code>StringBuilder</code>:</p>
<p><span id="more-74"></span></p>
<pre class="brush: c#; ">

var sbArraySuite = TestSuite.Create(&quot;build Strings from Array&quot;, doubleArray, String.Join(&quot;&quot;, doubleArray.Select(d =&gt; String.Format(&quot;{0:0.00}\n&quot;, d)).ToArray()))
    .Add(input =&gt;
    {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i &lt; input.Length; i++)
            sb.AppendFormat(&quot;{0:0.00}\n&quot;, input[i]);
        return sb.ToString();
    }, &quot;For&quot;)
    .Add(input =&gt;
    {
        StringBuilder sb = new StringBuilder(); int length = input.Length;
        for (int i = 0; i &lt; length; i++)
            sb.AppendFormat(&quot;{0:0.00}\n&quot;, input[i]);
        return sb.ToString();
    }, &quot;ForHoistLength&quot;)
    .Add(input =&gt;
    {
        StringBuilder sb = new StringBuilder();
        foreach (double d in input)
            sb.AppendFormat(&quot;{0:0.00}\n&quot;, d);
        return sb.ToString();
    }, &quot;ForEach&quot;)
    .Add(IEnumerableForEachToString)
    .RunTests();

    ...

    static string IEnumerableForEachToString(IEnumerable&lt;double&gt; input)
    {
        StringBuilder sb = new StringBuilder();
        foreach (double d in input)
        {
            sb.AppendFormat(&quot;{0:0.00}\n&quot;, d);
        }
        return sb.ToString();
    }
</pre>
<p>Which gives these results:</p>
<pre>
============ build Strings from Array ============
For                        1,01
ForHoistLength             1,01
ForEach                    1,01
IEnumerableForEachToString 1,03

============ build Strings from List ============
For                        1,00
ForHoistLength             1,00
ForEach                    1,02
IEnumerableForEachToString 1,05
</pre>
<p>Suddenly the relative differences between for/foreach and array/list collapse to 1-5%. Which confirms my intuition that algorithms usually matter much more and such optimisations are quite useless. At least we all had good fun on a saturday <img src='http://dasz.at/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://dasz.at/index.php/2009/01/net-microbenchmarking/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
