<?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>Tamir Khason - Just code &#187; PLINQ</title>
	<atom:link href="http://khason.net/tag/plinq/feed/" rel="self" type="application/rss+xml" />
	<link>http://khason.net</link>
	<description>Take care of the sense, and the sounds will take care of themselves.</description>
	<lastBuildDate>Thu, 15 Apr 2010 13:25:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Book review: C# 2008 and 2005 Threaded Programming</title>
		<link>http://khason.net/blog/book-review-c-2008-and-2005-threaded-programming/</link>
		<comments>http://khason.net/blog/book-review-c-2008-and-2005-threaded-programming/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 21:42:28 +0000</pubDate>
		<dc:creator>Tamir</dc:creator>
				<category><![CDATA[BLOG]]></category>
		<category><![CDATA[blogging general]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[PLINQ]]></category>
		<category><![CDATA[promo]]></category>
		<category><![CDATA[review]]></category>
		<category><![CDATA[TECH]]></category>
		<category><![CDATA[thoughts]]></category>

		<guid isPermaLink="false">http://khason.net/blog/book-review-c-2008-and-2005-threaded-programming/</guid>
		<description><![CDATA[A couple of weeks ago, Packt publishing asked me to review Gastón C. Hillar book “C# 2008 and 2005 Threaded Programming: Beginner&#8217;s Guide”. They sent me a copy of this book and today, I’m ready to write a review for it. But before I’ll start reviewing it, I want to apologize to the publisher and [...]

<p/>]]></description>
			<content:encoded><![CDATA[<p>A couple of weeks ago, <a href="http://www.packtpub.com/" target="_blank">Packt publishing</a> asked me to review Gastón C. Hillar book “<a href="http://www.packtpub.com/beginners-guide-for-C-sharp-2008-and-2005-threaded-programming/book" target="_new">C# 2008 and 2005 Threaded Programming: Beginner&#8217;s Guide</a><img style="margin: 0px; border-top-style: none! important; border-right-style: none! important; border-left-style: none! important; border-bottom-style: none! important" height="1" alt="" src="http://www.assoc-amazon.com/e/ir?t=israkniga-20&amp;l=as2&amp;o=1&amp;a=1847197108" width="1" border="0" />”. They sent me a copy of this book and today, I’m ready to write a review for it. But before I’ll start reviewing it, I want to apologize to the publisher and author for the impartial review.</p>
<p><a href="http://www.amazon.com/gp/product/1847197108?ie=UTF8&amp;tag=israkniga-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1847197108" target="_new"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="420" alt="image" src="http://khason.net/images/2009/03/image.png" width="340" border="0" /></a></p>
<p>First of all, you should understand, that <a href="http://www.amazon.com/gp/product/1847197108?ie=UTF8&amp;tag=israkniga-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1847197108" target="_new">this book</a> is about <strong>how</strong> it possible (for this book author) to write four programs (with awful user interface) using different classes from System.Threading namespace to perform tasks, rather then <strong>what </strong>is multithreaded programming and how to achieve best performance by utilizing multiple CPU power. Your own programs will not run faster after reading this book, but you’ll probably know (if you did not know before) how to use <a title="Read MSDN documentation about System.ComponentModel.BackgroundWorker class" href="http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx" target="_blank" rel="tag">BackgroundWorker</a>, <a title="Read MSDN documentation about System.Threading.Thread class" href="http://msdn.microsoft.com/en-us/library/system.threading.thread.aspx" target="_blank" rel="tag">Thread</a>, <a title="Read MSDN documentation about System.Threading.ThreadPool Class" href="http://msdn.microsoft.com/en-us/library/system.threading.threadpool.aspx" target="_blank" rel="tag">ThreadPool</a>, <a title="Read MSDN documentation about System.Threading.AutoResetEvent Class" href="http://msdn.microsoft.com/en-us/library/system.threading.autoresetevent.aspx" target="_blank" rel="tag">AutoResetEvent</a> and <a title="Read MSDN documentation about System.Threading.WaitHandle Class" href="http://msdn.microsoft.com/en-us/library/system.threading.waithandle.aspx" target="_blank" rel="tag">WaitHandle</a> classes. Also, there is a small chapter about thread context switching for UI thread delegates invocation and <a href="http://msdn.microsoft.com/en-us/concurrency/default.aspx" target="_blank">parallel extensions</a>.</p>
<p>There are some technical misconceptions and errors in this book. But it is not the major problem of it. The problem is that while reading this book I question myself whom this book aimed at? Language style is somewhere between blog chatting (better then mine) and <a href="http://msdn.microsoft.com/en-us/library/ms684841(VS.85).aspx" target="_blank">MSDN style documentation</a>. I admit I don’t know quite how to categorize this, the author writes in a style that is just bizarre (even more bizarre then mine in this blog <img src='http://khason.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ) Overall, it sounds like I’m reading a conversation between two beginner-level programmers trying to explain one each other why they are using certain coding convention in C#.</p>
<p>Another half of this 395 pages book is just copy-paste stuff from Visual Studio (including it default tabulations and indentations). Here one of representative examples of such copy/paste</p>
<blockquote><p>// Disable the Start button      <br />butStart.Enabled = false;       <br />// Enable the Start button       <br />butStart.Enabled = true;       </p>
<p>…       </p>
<p>// Some very useful property, which used as private member for another public property       <br />private int priVeryUserfulProperty; </p>
</blockquote>
<blockquote><p>public int VeryUserfulProperty      <br />{       <br />&#160;&#160; get       <br />&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160; return priVeryUserfulProperty;       <br />&#160;&#160; }       <br />&#160;&#160; set       <br />&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160; priVeryUserfulProperty = value;       <br />&#160;&#160; }       <br />}</p>
</blockquote>
<p><strong>Verdict</strong>: Not very exemplary introduction to some classes inside System.Threading namespace for fellow students who like to read blogs, rather then books and documentation and do not want to understand how it works under the hoods, but write something and forget it. </p>
<p><strong>3- of 5</strong> on my scale. <a href="http://www.packtpub.com/beginners-guide-for-C-sharp-2008-and-2005-threaded-programming/book" target="_blank">This book</a> is not <strong>all</strong> bad, though, but apparently suitable for very specific audience, which definitely excludes me.</p>


<p/>]]></content:encoded>
			<wfw:commentRss>http://khason.net/blog/book-review-c-2008-and-2005-threaded-programming/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Just released: Parallel Extensions – June CTP</title>
		<link>http://khason.net/blog/just-released-parallel-extensions-%e2%80%93-june-ctp/</link>
		<comments>http://khason.net/blog/just-released-parallel-extensions-%e2%80%93-june-ctp/#comments</comments>
		<pubDate>Mon, 02 Jun 2008 20:32:02 +0000</pubDate>
		<dc:creator>Tamir</dc:creator>
				<category><![CDATA[BLOG]]></category>
		<category><![CDATA[.NET 3.5]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[PLINQ]]></category>
		<category><![CDATA[promo]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[XLINQ]]></category>

		<guid isPermaLink="false">http://khason.net/blog/just-released-parallel-extensions-%e2%80%93-june-ctp/</guid>
		<description><![CDATA[Today, Parallel Programming team released 2nd CTP for Parallel Extensions to .NET Framework 3.5. Major features in this CTP are declarative parallelist (LINQ-to-Object, LINQ-to-XML), parallel tasks and imperative data and, the most important (for me) – user mode work stealing scheduler. It makes very efficient use of parallel hardware. Additional information regarding this release can [...]

<p/>]]></description>
			<content:encoded><![CDATA[<p>Today, <a href="http://msdn.microsoft.com/concurrency ">Parallel Programming</a> team <a href="http://blogs.msdn.com/pfxteam/archive/2008/06/02/8567802.aspx">released</a> 2nd CTP for Parallel Extensions to .NET Framework 3.5. Major features in this CTP are declarative parallelist (LINQ-to-Object, LINQ-to-XML), parallel tasks and imperative data and, the most important (for me) – user mode work stealing scheduler. It makes very efficient use of parallel hardware. Additional information regarding this release can be found in <a href="http://blogs.msdn.com/pfxteam/archive/2008/06/02/8567093.aspx">team blog</a>. Also, please, report bugs to <a href="https://connect.microsoft.com/site/sitehome.aspx?SiteID=516">Connect</a> in order to help those guys to produce better product.</p>
<p><a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=348F73FD-593D-4B3C-B055-694C50D2B0F3&amp;displaylang=en">Download June CTP of Parallel Extensions to .NET 3.5 &gt;&gt;</a></p>


<p/>]]></content:encoded>
			<wfw:commentRss>http://khason.net/blog/just-released-parallel-extensions-%e2%80%93-june-ctp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Parallel programming? Well, it’s all about CPU affinity or how to set processor affinity in WPF</title>
		<link>http://khason.net/blog/parallel-programming-well-it%e2%80%99s-all-about-cpu-affinity-or-how-to-set-processor-affinity-in-wpf/</link>
		<comments>http://khason.net/blog/parallel-programming-well-it%e2%80%99s-all-about-cpu-affinity-or-how-to-set-processor-affinity-in-wpf/#comments</comments>
		<pubDate>Mon, 14 Apr 2008 15:57:08 +0000</pubDate>
		<dc:creator>Tamir</dc:creator>
				<category><![CDATA[BLOG]]></category>
		<category><![CDATA[.NET 3.5]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[PLINQ]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://khason.net/blog/parallel-programming-well-it%e2%80%99s-all-about-cpu-affinity-or-how-to-set-processor-affinity-in-wpf/</guid>
		<description><![CDATA[Parallel computing is very cool technology, that makes you able to leverage tasks between processors in your system. Today it&#8217;s already impossible to buy single processor computer &#8211; when you&#8217;ll buy new PC, you&#8217;ll probably get dual core CPU at least. Today we&#8217;ll speak about how to manage affinities of tasks between CPUs in your [...]

<p/>]]></description>
			<content:encoded><![CDATA[<p><a href="http://msdn2.microsoft.com/en-us/concurrency/default.aspx" target="_blank">Parallel computing</a> is very cool technology, that makes you able to leverage tasks between processors in your system. Today it&#8217;s already impossible to buy single processor computer &#8211; when you&#8217;ll buy new PC, you&#8217;ll probably get dual core CPU at least. Today we&#8217;ll speak about how to manage affinities of tasks between CPUs in your system. For this purpose we&#8217;ll create a small game, named CoreWars. So, let&#8217;s the show begin.</p>
<p><img border="0" alt="image" src="http://khason.net/images/2008/12/image-77c3d41d-d8dc-4358-93b2-cd00752a434a.png" width="625" height="367" /> </p>
<p>What we want to do? Simple game, that includes some complicated math, executed large number of times. Here the code of one Dice roll</p>
<blockquote><p>void SetDice()     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; List&lt;Dice&gt; dices = new List&lt;Dice&gt;();      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; for (int i = 0; i &lt; MaxTries; i++)      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; double x = rnd.NextDouble();      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; double y = rnd.NextDouble();      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; double g = (Math.Pow(x, 2) + Math.Pow(y, 2) &#8211; rnd.Next()) / (Math.Sqrt(2) * y + Math.Sqrt(2) * ((x &#8211; Math.Sqrt(2)) &#8211; 1));      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; dices.Add((Dice)((int)g &amp; 0&#215;3));      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; int mP = dices.Count(dice =&gt; dice == Dice.Paper);      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; int mR = dices.Count(dice =&gt; dice == Dice.Rock);      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; int mS = dices.Count(dice =&gt; dice == Dice.Scissors); </p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; int m = (mP &gt; mR) ? mP : mR;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; m = (m &gt; mS) ? m : mS; </p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; CurrentDice = (Dice)((m &amp; 0&#215;3) % 0&#215;3);     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
</blockquote>
<p>Don&#8217;t even try to understand what&#8217;s going on here. The result is one dice state Paper, Rock or Scissors (the old kinds game). Now we want to run this number of times and affine each thread to one of our system&#8217;s core. How to do it? </p>
<p>Simple way &#8211; ask what thread are you running, then use ProcessorAffinity property of the ProcessThread to your CPU id.</p>
<blockquote><p>ProcessThread t = Process.GetCurrentProcess().Threads.OfType&lt;ProcessThread&gt;().Single(pt =&gt; pt.Id == AppDomain.GetCurrentThreadId());     <br />t.ProcessorAffinity = (IntPtr)(int)cpuID;</p>
</blockquote>
<p>Very good, but what&#8217;s this warning about &#8220;System.AppDomain.GetCurrentThreadId()&#8217; is obsolete: &#8216;AppDomain.GetCurrentThreadId has been deprecated because it does not provide a stable Id when managed threads are running on fibers (aka lightweight threads). To get a stable identifier for a managed thread, use the ManagedThreadId property on Thread.&#160; <a href="http://go.microsoft.com/fwlink/?linkid=14202">http://go.microsoft.com/fwlink/?linkid=14202</a> &#8221; ? Why this happens to me? The simple answer is Thread Processor Affinity never was most reliable thing in Windows (as well as ThreadID). But we still want to make it. What to do? </p>
<p>Let&#8217;s go a bit unmanaged. We&#8217;ll use <a href="http://msdn2.microsoft.com/en-us/library/ms686247.aspx" target="_blank">SetThreadAffinityMask</a> and <a href="http://msdn2.microsoft.com/en-us/library/ms683183(VS.85).aspx" target="_blank">GetCurrentThread</a> WinAPI methods to achieve what we want to.</p>
<blockquote><p>[DllImport(&quot;kernel32.dll&quot;)]     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; static extern IntPtr GetCurrentThread();      <br />[DllImport(&quot;kernel32.dll&quot;)]      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; static extern IntPtr SetThreadAffinityMask(IntPtr hThread, IntPtr dwThreadAffinityMask);      <br />&#8230;      <br />SetThreadAffinityMask(GetCurrentThread(), new IntPtr(1 &lt;&lt; (int)cpuID));      <br />&#8230;      <br />SetThreadAffinityMask(GetCurrentThread(), new IntPtr(0));</p>
</blockquote>
<p>So far, so good. Now threads. This step is very trivial</p>
<blockquote><p>ParameterizedThreadStart pts = new ParameterizedThreadStart(dr.ThrowDices);     <br />Thread t = new Thread(pts);      <br />t.SetApartmentState(ApartmentState.MTA);      <br />t.IsBackground = true;      <br />t.Start(i);</p>
</blockquote>
<p>We need also context switch (you remember, WPF)   </p>
<blockquote><p>ThreadPool.QueueUserWorkItem(delegate     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; int w = WaitHandle.WaitAny(wcs);      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Dispatcher.Invoke(DispatcherPriority.Background, (SendOrPostCallback)delegate(object o)      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; tb.Text = string.Format(&quot;The winner is CPU #{0}&quot;, o);      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }, w);      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; });</p>
</blockquote>
<p>Now, what to do with binding? To Bind or not to Bind &#8211; that is the question! My answer is to bind! Remember, you need also a small piece of CPU time to process UI events and push frames in renderring thread. Let&#8217;s roll dices.</p>
<blockquote><p>SetThreadAffinityMask(GetCurrentThread(), new IntPtr(1 &lt;&lt; (int)cpuID)); </p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; App.Current.Dispatcher.Invoke(DispatcherPriority.Background, (SendOrPostCallback)delegate     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; base.Clear(); </p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (CollectionChanged != null)     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; CollectionChanged(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset, null));      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }, null); </p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; for (int i = 0; i &lt; MaxIteractions; i++)     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; DiceRoller dr = new DiceRoller();      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; App.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, (SendOrPostCallback)delegate      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; base.Add(dr); </p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (CollectionChanged != null)     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; CollectionChanged(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, dr));      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }, null);      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; SetThreadAffinityMask(GetCurrentThread(), new IntPtr(0));      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ResetEvent.Set();</p>
</blockquote>
<p>Also do not forget to implement INotifyCollectionChanged on result collection and INotifyPropertyChanged on dice object.</p>
<p>After all preparations done, we can start to build basic user interface for the presentation layer. Main window</p>
<blockquote><p>&lt;StackPanel Name=&quot;Root&quot;&gt;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;StackPanel Name=&quot;LayoutRoot&quot; Orientation=&quot;Horizontal&quot;/&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;Button Content=&quot;Start battle&quot; Click=&quot;Button_Click&quot;/&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;TextBlock Name=&quot;tb&quot; TextAlignment=&quot;Center&quot; FontSize=&quot;15&quot; Visibility=&quot;Collapsed&quot;/&gt;      <br />&#160;&#160;&#160; &lt;/StackPanel&gt;</p>
</blockquote>
<p>Templates</p>
<blockquote><p>&lt;DataTemplate DataType=&quot;{x:Type l:DiceRoller}&quot; x:Key=&quot;drt&quot;&gt;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;Rectangle Width=&quot;5&quot; Height=&quot;5&quot;&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;Rectangle.Style&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;Style&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;Style.Triggers&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;DataTrigger Binding=&quot;{Binding Path=CurrentDice}&quot; Value=&quot;Paper&quot;&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;Setter Property=&quot;Rectangle.Fill&quot; Value=&quot;Red&quot;/&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/DataTrigger&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;DataTrigger Binding=&quot;{Binding Path=CurrentDice}&quot; Value=&quot;Rock&quot;&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;Setter Property=&quot;Rectangle.Fill&quot; Value=&quot;Black&quot;/&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/DataTrigger&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;DataTrigger Binding=&quot;{Binding Path=CurrentDice}&quot; Value=&quot;Scissors&quot;&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;Setter Property=&quot;Rectangle.Fill&quot; Value=&quot;Blue&quot;/&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/DataTrigger&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/Style.Triggers&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/Style&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/Rectangle.Style&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/Rectangle&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/DataTemplate&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;ItemsPanelTemplate x:Key=&quot;wpt&quot;&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;WrapPanel/&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/ItemsPanelTemplate&gt;</p>
</blockquote>
<p>We done. the only task to perform is to detect the number of CPUs in the system and put appropriate number of content controls to show the race result. Do not forget binding too.</p>
<blockquote><p>pc = Environment.ProcessorCount; </p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; for (int i = 0; i &lt; pc; i++)     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; HeaderedContentControl hcc = new HeaderedContentControl();      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; hcc.Width = this.Width / pc;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; hcc.HorizontalAlignment = HorizontalAlignment.Stretch;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; hcc.Header = string.Format(&quot;CPU {0}&quot;,i); </p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ItemsControl ic = new ItemsControl();     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ic.ItemsPanel = Resources[&quot;wpt&quot;] as ItemsPanelTemplate;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ic.ItemTemplate = Resources[&quot;drt&quot;] as DataTemplate;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; hcc.Content = ic;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; LayoutRoot.Children.Add(hcc); </p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; DiceRollers dr = new DiceRollers();     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; this.Resources.Add(string.Format(&quot;roller{0}&quot;, i),dr);&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Binding b = new Binding();     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; b.Source = dr;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; b.IsAsync = true;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; b.BindsDirectlyToSource = true;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; b.Mode = BindingMode.OneTime;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ic.SetBinding(ItemsControl.ItemsSourceProperty, b);      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
</blockquote>
<p>That&#8217;s all. Now we can race our dices and see what CPU works better. For real life scenario, this sample looks absolutely stupid, but just thing about processor affinity in <a href="http://khason.net/blog/software-is-sucks-probably-it-really-is/" target="_blank">Parallel Extension CTP</a> &#8211; why not to make us able to use it? The answer is &#8211; K.I.S.S (keep it simple, stupid). And as for me, I do not like to be stupid and I want to manage affinities! I need <a href="http://khason.net/blog/how-to-high-performance-graphics-in-wpf/" target="_blank">high performance for my applications</a> and only me can decide to which processor dispatch which task and how.</p>
<p>Have a nice day and be good people.</p>
<p>Source code for this article.</p>
<div style="padding-right: 0px; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px; display: inline" id="scid:4c033bbc-1f2f-4686-a55f-26926c847a06:6239b869-0ae3-4aec-95c7-8ad46f10d308" class="wlWriterSmartContent">
<p><a href="http://blogs.microsoft.co.il/blogs/tamir/WindowsLiveWriter/ParallelprogrammingWellitsallaboutCPUaff_E03E/CoreWars_1.zip" title="CoreWars.zip [61.4 Kb]">CoreWars.zip [61.4 Kb]</a></p>
</div>


<p/>]]></content:encoded>
			<wfw:commentRss>http://khason.net/blog/parallel-programming-well-it%e2%80%99s-all-about-cpu-affinity-or-how-to-set-processor-affinity-in-wpf/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Some new post-mix downloads</title>
		<link>http://khason.net/blog/some-new-post-mix-downloads/</link>
		<comments>http://khason.net/blog/some-new-post-mix-downloads/#comments</comments>
		<pubDate>Tue, 11 Mar 2008 10:01:44 +0000</pubDate>
		<dc:creator>Tamir</dc:creator>
				<category><![CDATA[BLOG]]></category>
		<category><![CDATA[.NET 3.5]]></category>
		<category><![CDATA[blogging general]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[PLINQ]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[soft]]></category>
		<category><![CDATA[Vista]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[VSTS]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Windows Live]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[XNA]]></category>

		<guid isPermaLink="false">http://khason.net/blog/some-new-post-mix-downloads/</guid>
		<description><![CDATA[Today is download day at MSDN. There are some very interesting things published. New release of Windows SDK (new classes for WPF 3.5, bugs fixes, and enhanced support for Windows Server 2008, including speech, error reporting and UAC). Download it here. For more information, visit SDK blog Windows XP SP3 RC2 (it&#8217;s not final release), [...]

<p/>]]></description>
			<content:encoded><![CDATA[<p>Today is download day at MSDN. There are some very interesting things published. </p>
<ul>
<li>New release of Windows SDK (new classes for WPF 3.5, bugs fixes, and enhanced support for Windows Server 2008, including speech, error reporting and UAC). <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=e6e1c3df-a74f-4207-8586-711ebe331cdc&amp;amp;DisplayLang=en">Download it here</a>. For more information, <a href="http://blogs.msdn.com/windowssdk/archive/2008/03/01/integrating-windows-sdk-and-vs-with-new-sdk-configuration-tool.aspx">visit SDK blog</a></li>
<li>Windows XP SP3 RC2 (it&#8217;s not <a target="_blank" href="http://www.microsoft.com/downloads/details.aspx?FamilyID=68c48dad-bc34-40be-8d85-6bb4f56f5110&amp;amp;DisplayLang=en">final release</a>), but if you want to try it (not in production environment) <a target="_blank" href="http://www.microsoft.com/downloads/details.aspx?FamilyID=114f3599-12af-42b2-aab1-b969a62c68a7&amp;amp;DisplayLang=en">download it here</a>. As well as if you are ready to harm your system. Give a try to <a target="_blank" href="http://www.microsoft.com/downloads/details.aspx?FamilyID=1a2e3ddd-b38b-439d-bba7-f179a5d3ecaf&amp;amp;DisplayLang=en">Windows Internet Explorer 8 Beta 1 for XP</a> (or for <a target="_blank" href="http://www.microsoft.com/downloads/details.aspx?FamilyID=c3c6e8c1-bd91-490b-86f5-f3652dd691de&amp;amp;DisplayLang=en">Vista/Home Server 2008</a>, or <a target="_blank" href="http://www.microsoft.com/downloads/details.aspx?FamilyID=f2e76e1f-7592-4d74-a558-3cca1d7b5592&amp;amp;DisplayLang=en">Windows Server 2003 SP2</a>).</li>
<li>There are <a target="_blank" href="http://www.microsoft.com/downloads/details.aspx?FamilyID=df80d533-ba87-40b4-abe2-1ef12ea506b7&amp;amp;DisplayLang=en">some fixes for Microsoft XNA Game Studio 2.0</a> (make sure, that you know what is it. If not, come to see my TechEd session). Also, you can <a target="_blank" href="http://www.microsoft.com/downloads/details.aspx?FamilyID=d6a69b9f-2aef-4125-b162-edf0ae922caf&amp;amp;DisplayLang=en">download Games for Windows &#8211; LIVE redistributable</a> .</li>
<li>If you are lucky Zune owner, you can <a target="_blank" href="http://www.microsoft.com/downloads/details.aspx?FamilyID=6136349f-2b32-4946-83b5-a09775531ef4&amp;amp;DisplayLang=en">download PC software 2.3 for it</a></li>
<li>If you Virtual Earth fun, <a target="_blank" href="http://www.microsoft.com/downloads/details.aspx?FamilyID=e9298080-50c4-4f2e-9fc4-4009074996ba&amp;amp;DisplayLang=en">add realistic 3D capabilities</a> to use <a target="_blank" href="http://maps.live.com">online Live Search Maps</a>.</li>
<li>If you still have no Silverlight Tools for VS2008, be sure <a target="_blank" href="http://www.microsoft.com/downloads/details.aspx?FamilyID=e0bae58e-9c0b-4090-a1db-f134d9f095fd&amp;amp;DisplayLang=en">to download it</a> (this is not chained installer, tools only)</li>
</ul>
<p>Enough for this morning. Warm up your download machines and start downloading.</p>


<p/>]]></content:encoded>
			<wfw:commentRss>http://khason.net/blog/some-new-post-mix-downloads/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>How to: High performance graphics in WPF</title>
		<link>http://khason.net/blog/how-to-high-performance-graphics-in-wpf/</link>
		<comments>http://khason.net/blog/how-to-high-performance-graphics-in-wpf/#comments</comments>
		<pubDate>Sun, 02 Mar 2008 19:38:00 +0000</pubDate>
		<dc:creator>Tamir</dc:creator>
				<category><![CDATA[BLOG]]></category>
		<category><![CDATA[.NET 3.5]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[PLINQ]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://khason.net/blog/how-to-high-performance-graphics-in-wpf/</guid>
		<description><![CDATA[Microsoft DPE: &#8220;WPF is ever best super performance oriented technology for creating hyper multi point graphs, using parallelism and huge in-memory persistence vector scrounged math distributed calculations&#8230; And ever more with branded new Microsoft Windows Vista 7. Client: Errr, well&#8230;. Let&#8217;s try to apply it for our VB program&#8230; DPE: You can easily do it [...]

<p/>]]></description>
			<content:encoded><![CDATA[<blockquote>
<p><a href="http://acronyms.thefreedictionary.com/Developer+and+Platform+Evangelist+(Microsoft)" target=_blank mce_href="http://acronyms.thefreedictionary.com/Developer+and+Platform+Evangelist+(Microsoft)"><em>Microsoft DPE</em></a>: &#8220;WPF is ever best super performance oriented technology for creating hyper multi point graphs, using parallelism and huge in-memory persistence vector scrounged math distributed calculations&#8230; And ever more with branded new Microsoft Windows Vista 7.</p>
<p><em>Client</em>: Errr, well&#8230;. Let&#8217;s try to apply it for our VB program&#8230;</p>
<p><em>DPE</em>: You can easily do it yourself, but it&#8217;d be better to call someone from Microsoft Consulting Services.</p>
<p><em>Client</em>: Let it be&#8230;</p>
<p><a href="http://www.microsoft.com/services/microsoftservices/default.mspx" target=_blank mce_href="http://www.microsoft.com/services/microsoftservices/default.mspx"><em>MCS</em></a>: Well. It&#8217;s too huge for WPF to scale&#8230; WPF uses a retained rendering system. It saves every little pixel and make you able scale and repaint very often without the composition system blocking on callbacks to your code. However, 1,000,000 retained pixels is too huge to scale&#8230;</p>
<p><em>Client</em>: I want it scale. They promised&#8230; They told, it&#8217;ll scale. Make it to do what I want it to do!!!</p>
<p><em>MCS</em>: Errr, well. Let it be!</p>
</blockquote>
<p>This is very common dialog between DPE, MCS and clients. Sales men want it to do, what he need it to do. Client want it to do what sales men promised to do and Services men should make it to do what they both want it to do. Today we&#8217;ll speak about retained, lazy and loose models to produce large scale graphics.</p>
<h3>First problem: multithreading</h3>
<p>Even before we start to work, you should know, that we cannot create dependency objects in thread other, then current UI thread. We can use locks, mutexes, semaphores, however we still can not create Dependency Objects in other thread. In order to get rid of it, we&#8217;ll have to use INofityPropertyChanged implementation, instead of Dependency Objects. This means, no Dependency Properties. </p>
<p>So, we&#8217;ll start with following code (I&#8217;ll reuse <a href="http://langexplr.blogspot.com/2007/12/creating-fractal-images-with-c-30.html" target=_blank mce_href="http://langexplr.blogspot.com/2007/12/creating-fractal-images-with-c-30.html">nice code written by Luis Diego Fallas</a> to create Mandelbrot Fractal set)</p>
<p>class FractsCollection : INotifyPropertyChanged <br />&nbsp;&nbsp;&nbsp; {</p>
<h3>Second problem: rendering thread</h3>
<p>Well, the problem is knows. There is only one UI thread. We wont it be only one, so we&#8217;ll use <a href="http://blogs.msdn.com/dwayneneed/archive/2007/04/26/multithreaded-ui-hostvisual.aspx" target=_blank mce_href="http://blogs.msdn.com/dwayneneed/archive/2007/04/26/multithreaded-ui-hostvisual.aspx">our own HostVisual by Dwayne Need</a> to enhance the performance.</p>
<h3>Third problem: Retained objects</h3>
<p>Actually, this is not problem. This is feature. And it can be extremely useful if you want to retain layout. Let&#8217;s create a simple example: <a href="http://en.wikipedia.org/wiki/Dragon_curve" target=_blank mce_href="http://en.wikipedia.org/wiki/Dragon_curve">Dragon curve</a> fractal. It has limited number of points, generated by well known final algorithm. So, we&#8217;ll create our own geometry, derived from Shape class. The fasted geometry is StreamGeometry, so let&#8217;s use it. First of all let&#8217;s create the class and save the array of points.</p>
<blockquote>
<p>public class DragonShape:Shape <br />&nbsp;&nbsp;&nbsp; { <br />StreamGeometry dragonGeometry; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; double _angle; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; List&lt;Point&gt; Points;</p>
</blockquote>
<p>Then we&#8217;ll generate the pattern</p>
<blockquote>
<p>void GeneratePattern() <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ThreadPool.QueueUserWorkItem(delegate <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br />Move(5); <br />Turn(GetNextPoint * System.Math.PI / 180.0);</p>
</blockquote>
<p>Then, by overriding DefiningGeometry property, create the fractal</p>
<blockquote>
<p>protected override System.Windows.Media.Geometry DefiningGeometry <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get {&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; using (StreamGeometryContext context = dragonGeometry.Open()) <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; context.BeginFigure(Points[0], false, false); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; context.PolyLineTo(Points, true, false); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return (Geometry)dragonGeometry.GetAsFrozen();} <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p>
</blockquote>
<p>Don&#8217;t forget to tell the shape, that geometry was changed</p>
<blockquote>
<p>this.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, (SendOrPostCallback)delegate <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.InvalidateVisual(); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }, null);</p>
</blockquote>
<p>Now, run it and we&#8217;ll have very nice vector fractal generated that can be easily resized and scaled. Here the result.</p>
<p><img height=361 alt=image src="http://blogs.microsoft.co.il/blogs/tamir/WindowsLiveWriter/HowtoHighperformancegraphicsinWPF_11392/image_e6c30165-ac18-4fea-9ceb-b21f4efd4831.png" width=336 border=0 mce_src="http://blogs.microsoft.co.il/blogs/tamir/WindowsLiveWriter/HowtoHighperformancegraphicsinWPF_11392/image_e6c30165-ac18-4fea-9ceb-b21f4efd4831.png"/>&nbsp;<img height=373 alt=image src="http://blogs.microsoft.co.il/blogs/tamir/WindowsLiveWriter/HowtoHighperformancegraphicsinWPF_11392/image_0d473dcc-906a-47ad-8b78-c3aa300f1672.png" width=390 border=0 mce_src="http://blogs.microsoft.co.il/blogs/tamir/WindowsLiveWriter/HowtoHighperformancegraphicsinWPF_11392/image_0d473dcc-906a-47ad-8b78-c3aa300f1672.png"/> </p>
<p>This method will work fine for 1,000, even 10,000 points. But after a while you&#8217;ll experience performance degradation. What to do? The client wants 10,000,000 (!) points (and in Winforms GDI+ it works for him)</p>
<p>Let&#8217;s try to understand why. Because it is not retain. It&#8217;s image! So, let&#8217;s use image to make the play fair.</p>
<p>The fastest BitmapSource is InteropBitmap. It has an ability to update itself from the memory section. That&#8217;s exactly what we&#8217;ll use</p>
<blockquote>
<p>format = PixelFormats.Bgr32; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; max = format.BitsPerPixel; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; uint count = (uint)(sWidth * sHeight * format.BitsPerPixel / 8); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; section = CreateFileMapping(new IntPtr(-1), IntPtr.Zero, 0&#215;04, 0, count, null); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; map = MapViewOfFile(section, 0xF001F, 0, 0, count); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pixels = new byte[count]; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Marshal.Copy(pixels, 0, map, (int)count); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; source = System.Windows.Interop.Imaging.CreateBitmapSourceFromMemorySection(section, (int)sWidth, (int)sHeight, format, (int)(sWidth * format.BitsPerPixel / 8), 0) as InteropBitmap; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ThreadPool.QueueUserWorkItem(delegate <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while (true) <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Generate(); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; });</p>
</blockquote>
<p>To get the source to bind to we&#8217;ll get frozen image. Call Invalidate first to reread the source.</p>
<blockquote>
<p>InteropBitmap source; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public BitmapSource Source <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; source.Invalidate(); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return (BitmapSource)source.GetAsFrozen(); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p>
</blockquote>
<p>Now, when we ready to display we can just put pixels simultaneously (by using Parallel extension and PLINQ) and tell the WPF that our count and ImageSource property updated upon each pixel.</p>
<blockquote>
<p>unsafe <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; uint* pBuffer = (uint*)map; <br />&nbsp;&nbsp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nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }) <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pBuffer[(int)(p.x + p.y * sWidth)] = (uint)(uint)((uint)0xFF &lt;&lt; 24) | <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (uint)(p.i &lt;&lt; 16) | <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (uint)(5*p.i &lt;&lt; <img src='http://khason.net/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /> | <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (uint)(15*p.i); ; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; count++; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FireUpdate(); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } </p>
<p>void FireUpdate() <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (PropertyChanged != null) <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PropertyChanged(this, new PropertyChangedEventArgs(&#8220;PixelCount&#8221;)); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PropertyChanged(this, new PropertyChangedEventArgs(&#8220;Source&#8221;)); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p>
</blockquote>
<p>We done. Now let&#8217;s see how fast it can be to generate and display <strong>10,000,000 live pixels </strong>(it&#8217;s about 16,000&#215;16,00x32bit image) in screen. The maximum, I was able to get with <a href="http://blogs.microsoft.co.il/blogs/tamir/archive/tags/Dell/default.aspx" target=_blank mce_href="http://blogs.microsoft.co.il/blogs/tamir/archive/tags/Dell/default.aspx">my Dell Latitude D820</a> was 1,200,000 x 1,200,000 pixels indexed 4 bit image (it&#8217;s about 100,000,000 points) and my memory is over <img src='http://khason.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><iframe style="WIDTH: 500px; HEIGHT: 375px" src="http://silverlight.services.live.com/invoke/17226/Frac/iframe.html" frameBorder=0 scrolling=no></iframe></p>
<p>Not bad, ah? So WPF scales and DPE are right? Not quite right, but let them to do their work and we&#8217;ll be behind to come all client&#8217;s dreams (and DPE&#8217;s promises) true.</p>
<p>Have a nice day and be good people. Now you can use WPF for drawing big number of points.</p>


<p/>]]></content:encoded>
			<wfw:commentRss>http://khason.net/blog/how-to-high-performance-graphics-in-wpf/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>
