<?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>Biggle&#039;s Blog &#187; Basta</title>
	<atom:link href="http://www.biggle.de/blog/tag/basta/feed" rel="self" type="application/rss+xml" />
	<link>http://www.biggle.de/blog</link>
	<description>Web- und Software Development</description>
	<lastBuildDate>Sat, 04 Sep 2010 14:59:00 +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>Neues in WPF 4</title>
		<link>http://www.biggle.de/blog/neues-in-wpf-4</link>
		<comments>http://www.biggle.de/blog/neues-in-wpf-4#comments</comments>
		<pubDate>Fri, 12 Mar 2010 10:10:57 +0000</pubDate>
		<dc:creator>Mario Priebe</dc:creator>
				<category><![CDATA[CSharp]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[Basta]]></category>
		<category><![CDATA[WPF4]]></category>

		<guid isPermaLink="false">http://www.biggle.de/blog/?p=4121</guid>
		<description><![CDATA[Ich hab kürzlich die BASTA Spring 2010 besucht (über 500 Teilnehmer). Es war wirklich eine sehr informative Veranstaltung über aktuelle Entwicklungen im .NET Bereich. Folgender Abriss soll die Neuerungen im .NET Framework 4.0, Entity Framework 2, VisualStudio 2010, WPF 4 und Silverlight 4, aufzeigen. Im folgenden Artikel möchte ich über einige Neuerungen in WPF 4.0  [...]]]></description>
			<content:encoded><![CDATA[<p>Ich hab kürzlich die BASTA Spring 2010 besucht (über 500 Teilnehmer). Es war wirklich eine sehr informative Veranstaltung über aktuelle Entwicklungen im .NET Bereich. Folgender Abriss soll die Neuerungen im .NET Framework 4.0, Entity Framework 2, VisualStudio 2010, WPF 4 und Silverlight 4, aufzeigen.</p>
<p><a href="http://www.biggle.de/blog/wp-content/uploads/2010/03/bastalogo14.jpg"><img class="alignnone size-full wp-image-4122" title="bastalogo1" src="http://www.biggle.de/blog/wp-content/uploads/2010/03/bastalogo14.jpg" alt="" width="500" height="77" /></a></p>
<p>Im folgenden Artikel möchte ich über einige Neuerungen in WPF 4.0  schreiben</p>
<p><br class="spacer_" /></p>
<h2>Visual StateManager</h2>
<p>Verbessertes Management von States und Transitions, das Aussehen wird durch VisualStates repräsentiert. Ein VisualState enthält eine Liste von StoryBoard-Objekten, welche beschreiben wie sich ein Element verändert.</p>
<ul type="disc">
<li>Methoden im VSM:      GoToElementState (ohne ControlElement), GoToState (mit ControlTemplate) </li>
<li>Ersetzt, bzw vereinfacht      Trigger </li>
<li>Von Silverlight übernommen,      somit kompatibel </li>
<li>In Blend 3 verfügbar </li>
</ul>
<p><a href="http://www.biggle.de/blog/wp-content/uploads/2010/03/visualstateManager.png"><img class="alignnone size-full wp-image-4123" title="visualstateManager" src="http://www.biggle.de/blog/wp-content/uploads/2010/03/visualstateManager.png" alt="" width="500" height="411" /></a></p>
<p>Quelle:</p>
<ul type="disc">
<li><a href="http://windowsclient.net/wpf/wpf35/wpf-35sp1-toolkit-visual-state-manager-overview.aspx">http://windowsclient.net/wpf/wpf35/wpf-35sp1-toolkit-visual-state-manager-overview.aspx</a> </li>
</ul>
<p><br class="spacer_" /></p>
<h2>Neue WPF Tools</h2>
<p>Die neuen WPF Tools stammen aus dem WPF Toolkit und wurden in der WPF 4.0 übernommen. Dieses sollen 99% kompatibel zu Silverlight sein.</p>
<ul type="disc">
<li>Datagrid </li>
<li>Unterstützt Validierung für      Zellen und Zeilen </li>
<li>DatePicker </li>
<li>Calendar </li>
<li>Anzeige kann mit DisplayMode      verändert werden </li>
<li>(Größe kann nur über      Transformer verändert werden) </li>
</ul>
<p><br class="spacer_" /></p>
<h2>Multitouch</h2>
<p>Toucheingaben werden unterstützt</p>
<ul type="disc">
<li>MultiTouch Events für      UIElement, UIElement3D und ContentElement über IsManipulationEnabled </li>
<li>TouchDown </li>
<li>TouchMove </li>
<li>TouchUp </li>
<li>TouchEnter </li>
<li>TouchLeave </li>
<li>GetTouchPoint (Returns the      current position of the touch device relative to specified element) </li>
<li>TouchDevice (Get the device,      that generated the event) </li>
<li>Device (Gets the input device      the initiated thid event &#8211; inherited from InputEventArgs) </li>
<li>IsManipulationEnabled: </li>
<li>ManipulationStarted </li>
<li>ManipulationDelta </li>
<li>ManipulationStarting </li>
<li>ManipulationComplited </li>
</ul>
<p>UIElement unterstützt auch Expansion, Scale, Rotation, Translation (ManipulationStarted, ManipulationDelta,&#8230;)</p>
<p>Quellen:</p>
<ul type="disc">
<li><a href="http://blogs.msdn.com/jaimer/">http://blogs.msdn.com/jaimer/</a> </li>
<li><a href="http://blogs.msdn.com/llobo/archive/2009/11/24/new-wpf-features-multitouch.aspx">http://blogs.msdn.com/llobo/archive/2009/11/24/new-wpf-features-multitouch.aspx</a></li>
</ul>
<p><br class="spacer_" /></p>
<h2>Grafik und Animation in WPF</h2>
<h3>Pixel Shader 3 Support</h3>
<ul type="disc">
<li>BitmapEffect-Property -&gt;      obsolete </li>
<li>Neu: Effect-Property </li>
<li>.NET 3.5 unterstützt bis      Version 2.0 </li>
</ul>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">RenderCapability<span style="color: #339933;">.</span>IsPixelShaderVersionSupported<span style="color: #009900;">&#40;</span>majorversion<span style="color: #339933;">,</span>minorVersion<span style="color: #009900;">&#41;</span>
RenderCapability<span style="color: #339933;">.</span> IsPixelShaderVersionSupportedlnSoftware <span style="color: #009900;">&#40;</span>majorversion<span style="color: #339933;">,</span>minorVersion<span style="color: #009900;">&#41;</span>
RenderCapability<span style="color: #339933;">.</span> MaxPixelShaderlnstructionSlots<span style="color: #009900;">&#40;</span>majorversion<span style="color: #339933;">,</span>minorVersion<span style="color: #009900;">&#41;</span></pre></td></tr></table></div>

<p><br class="spacer_" /></p>
<h3>Layout-Rounding</h3>
<ul type="disc">
<li>UseLayoutRounding=&#8221;true&#8221;      (erbt von FrameworkElement) </li>
<li>Vererbbar </li>
<li>In Silverlight default</li>
<li><a href="http://www.biggle.de/blog/wp-content/uploads/2010/03/layoutrounding.png"><img class="alignnone size-full wp-image-4124" title="layoutrounding" src="http://www.biggle.de/blog/wp-content/uploads/2010/03/layoutrounding.png" alt="" width="63" height="149" /></a></li>
</ul>
<p>Quellen:</p>
<ul type="disc">
<li><a href="http://blogs.msdn.com/text/archive/2009/08/27/layout-rounding.aspx">http://blogs.msdn.com/text/archive/2009/08/27/layout-rounding.aspx</a></li>
</ul>
<p><br class="spacer_" /></p>
<h3>ClearTypeHint</h3>
<p>Soll das TextRendering erheblich verbessern, in Silverlight 3 wird ClearTypeHint offiziell schon unterstützt. Hierzu muss die Property RenderOptions.ClearTypeHint auf Enabled gestellt werden.</p>
<p>Durch verschiedene Beeinflussung kann die Property den Status verlieren (Effect, OpacityMask, VisualBrush, DrawingBrush, Clip, and Opacity) Kann aber dann aber wieder enabled werden. Folgende mögliche Ausnahmen sollen das verdeutlichen:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>Window AllowsTransparency<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;True&quot;</span> WindowStyle<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;None&quot;</span> RenderOptions<span style="color: #339933;">.</span>ClearTypeHint<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Enabled&quot;</span><span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>StackPanel<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>TextBlock Name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Block1&quot;</span><span style="color: #339933;">&gt;</span>This text will be rendered with ClearType<span style="color: #339933;">.&lt;/</span>TextBlock<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>TextBlock Opacity<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;0.9&quot;</span> Nane<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Block2&quot;</span> <span style="color: #339933;">&gt;</span>This text will be rendered with NO ClearType <span style="color: #009900;">&#40;</span>note the opacity Prop<span style="color: #009900;">&#41;</span><span style="color: #339933;">./&gt;</span>
 
  <span style="color: #339933;">&lt;</span>Grid Height<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;l00&quot;</span> Background<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;White&quot;</span><span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>Grid<span style="color: #339933;">.</span>Clip<span style="color: #339933;">&gt;</span>
      <span style="color: #339933;">&lt;</span>Ellipse3eometry RadiusX<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;300&quot;</span> RadiusY<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;200&quot;</span> Center<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;150, 120&quot;</span> <span style="color: #339933;">/&gt;</span>
    <span style="color: #339933;">&lt;/</span>Grid<span style="color: #339933;">.</span>Clip<span style="color: #339933;">&gt;</span>
 
  <span style="color: #339933;">&lt;</span>Grid<span style="color: #339933;">.</span> RowDefinitions<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>RowDefinition <span style="color: #339933;">/&gt;</span>
  <span style="color: #339933;">&lt;/</span>Grid<span style="color: #339933;">.</span>RowDefinition<span style="color: #339933;">&gt;</span>
 
  <span style="color: #339933;">&lt;</span>TextBlock Name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Block3&quot;</span><span style="color: #339933;">&gt;</span>This text will be rendered with NO ClearType <span style="color: #339933;">.</span> <span style="color: #339933;">&lt;/</span>TextBlock<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>TextBlock Name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Block4&quot;</span> Grid<span style="color: #339933;">.</span>Row<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;1&quot;</span> RenderOptions<span style="color: #339933;">.</span>ClearTypeMint<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Enabled&quot;</span><span style="color: #339933;">&gt;</span>This text will be rendered with ClearType<span style="color: #339933;">&lt;/</span>TextBlock<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;/</span>Grid<span style="color: #339933;">&gt;</span>
 
  <span style="color: #339933;">&lt;</span>TextBlock Name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Block5&quot;</span><span style="color: #339933;">&gt;</span>This text will be rendered with ClearType<span style="color: #339933;">.&lt;/</span>TextBlock<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>StackPanel<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>Window<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>Here the values are set as per the hierarchy</p>
<ul type="disc">
<li>Window -&gt; hint enabled </li>
<li>StackPanel -&gt; inherits      Hint (cleartype) </li>
<li>Blockl -&gt; inherits Hint      (cleartype) </li>
<li>Block2 -&gt; overrides Hint      because of Opacity [intermediate rendertarget] </li>
<li>Grid -&gt; overrides Hint      because of Clip [intermediate rendertarget] </li>
<li>Block3 -&gt; Inherits Grid‘s      hint (No cleartype) </li>
<li>Block4 -&gt; overrides Hint      to enabled (Cleartype) </li>
</ul>
<p>Quellen:</p>
<ul type="disc">
<li><a href="http://blogs.msdn.com/llobo/archive/2009/10/28/new-wpf-features-cleartypehint.aspx">http://blogs.msdn.com/llobo/archive/2009/10/28/new-wpf-features-cleartypehint.aspx</a></li>
</ul>
<p><br class="spacer_" /></p>
<h3>Cached Composition</h3>
<p>Spezieller Videospeicher, der das aktuelle Objekt vorhalten kann. Unterstützt somit das Manipulieren ohne neu zu Rendern. (GPU rendert aus dem Cache und entlastet die CPU)</p>
<ul type="disc">
<li>Bessere Performance </li>
<li>CacheModeProperty BitmapCache muss aktiviert werden </li>
<li>Vererbbar </li>
</ul>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>Canvas<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>Canvas<span style="color: #339933;">.</span>CacheMode<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>BitmapCache EnableClearType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;False&quot;</span> RenderAtScale<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;2&quot;</span> <span style="color: #339933;">/&gt;</span>
  <span style="color: #339933;">&lt;/</span>Canvas<span style="color: #339933;">.</span>CacheMode<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>Canvas<span style="color: #339933;">.</span>CacheMode<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;BitmapCache&quot;</span> <span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;/</span>Canvas<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<h3>Text Rendering Stack</h3>
<p>Klarerer, sauberer Text. Soll die Schärfe von Win32/GDI entsprechen</p>
<ul type="disc">
<li>ClearType </li>
<li>GrayScale </li>
<li>Aliased </li>
</ul>
<p><br class="spacer_" /></p>
<h3>Text Formatting Mode</h3>
<p>Bisher war es so, das klein skalierter Text nicht anständig gerendert wurde. Mit TextOptions.TextFormattingMode kann man hier nachhelfen</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>TextBox TextOptions<span style="color: #339933;">.</span>TextFormattingMode<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Ideal&quot;</span> FontSize<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;15&quot;</span> Text<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Hello World&quot;</span> <span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;</span>TextBox TextOptions<span style="color: #339933;">.</span>TextFormattingMode<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Display&quot;</span> FontSize<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;15&quot;</span> Text<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Hello World&quot;</span> <span style="color: #339933;">/&gt;</span></pre></td></tr></table></div>

<p><a href="http://www.biggle.de/blog/wp-content/uploads/2010/03/textFormattingMode.png"><img class="alignnone size-full wp-image-4125" title="textFormattingMode" src="http://www.biggle.de/blog/wp-content/uploads/2010/03/textFormattingMode.png" alt="" width="484" height="131" /></a></p>
<p><br class="spacer_" /></p>
<h3>Animation Easing Functions</h3>
<ul type="disc">
<li>Dieses Feature wurde aus      Silverlight 3 übernommen und kann in wenigen Schritten eine Animation auf      ein Element abspielen </li>
<li>In WPF wurden zuvor Trigger      anstelle dessen verwendet. </li>
<li>Somit sind auch die      Animationen ab WPF 4.0 zu Silverlight kompatibel </li>
<li>Verfügbar auch in Expression      Blend unter -&gt; WorkSpaces/Animation, in Klick in der Timeline auf      Effekt, gibt die Auswahl zu Easy Functions </li>
</ul>
<p><a href="http://www.biggle.de/blog/wp-content/uploads/2010/03/AnimationEasing.png"><img class="alignnone size-full wp-image-4126" title="AnimationEasing" src="http://www.biggle.de/blog/wp-content/uploads/2010/03/AnimationEasing.png" alt="" width="502" height="174" /></a></p>
<h3>Selection Brush (Caret Brush)</h3>
<p>Beeinflusst den Hintergrund von markierten Text</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">SelectionBrush<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;RED&quot;</span>
Selectionopacity<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;O.3&quot;</span> <span style="color: #009900;">&#40;</span><span style="color: #b1b100;">Default</span> value is <span style="color:#800080;">0.6</span><span style="color: #009900;">&#41;</span>
CaretBrush<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Red&quot;</span></pre></td></tr></table></div>

<p><br class="spacer_" /></p>
<h2>Binding in WPF 4.0</h2>
<p>Unterstützung von dynamischen Objekten (DynamcObject, IDynamicMetaObjectProvider)</p>
<h3>Bindable Run</h3>
<ul type="disc">
<li>Im RichTextEditor ist die      Dependency Property RUN nun bindable </li>
</ul>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>FlowDocumentReader<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>FlowDocument<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>Paragraph<span style="color: #339933;">&gt;</span>
      <span style="color: #339933;">&lt;</span>Run<span style="color: #339933;">&gt;</span>Sample Text Beginning<span style="color: #339933;">:&lt;/</span>Run<span style="color: #339933;">&gt;</span>
      <span style="color: #339933;">&lt;</span>Run Text<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;{Binding ElementName='tbl' ‚ Path=Text&quot;</span> <span style="color: #339933;">/&gt;</span>
      <span style="color: #339933;">&lt;</span>Run<span style="color: #339933;">&gt;</span>End of sample text<span style="color: #339933;">.&lt;/</span>Run<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;/</span>Paragraph<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;/</span>FlowDocument<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>FlowDocumentReader<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>Quellen:</p>
<ul type="disc">
<li><a href="http://blogs.msdn.com/text/archive/2009/09/01/bindable-run.aspx">http://blogs.msdn.com/text/archive/2009/09/01/bindable-run.aspx</a></li>
</ul>
<p><br class="spacer_" /></p>
<h3>Binding to dynamic objects</h3>
<p>Ermöglich das Binden an einen dynamischen Typen</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">dynamic dynamicObj <span style="color: #339933;">=</span> BindPanel<span style="color: #339933;">.</span>DataContext <span style="color: #339933;">;</span>
dynamicObj<span style="color: #339933;">.</span>A <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Simple Binding&quot;</span><span style="color: #339933;">;</span>
dynamicObj<span style="color: #339933;">.</span>B <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DynamicObjectClass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
dynamicObj<span style="color: #339933;">.</span>B<span style="color: #339933;">.</span>C <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Nested Prop Binding&quot;</span><span style="color: #339933;">;</span>
dynamicObj<span style="color: #339933;">.</span>Addltem<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;item 0&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
dynamicObj<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Indexer Binding&quot;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>Window<span style="color: #339933;">.</span>Resources<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>local<span style="color: #339933;">:</span>DynamicObjectClass x<span style="color: #339933;">:</span><span style="color: #990000;">Key</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;MyDynamicObject&quot;</span> <span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;/</span>Window<span style="color: #339933;">.</span>Resources<span style="color: #339933;">&gt;</span>
 
<span style="color: #339933;">&lt;</span>StackPanel Name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;BindPanel&quot;</span> DataContext<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;{StaticResource MyDynamicObject}&quot;</span><span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>TextBoxText<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;{Binding Path=A}&quot;</span> <span style="color: #339933;">/&gt;</span>
  <span style="color: #339933;">&lt;</span>TextBlock Text<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;{Binding Path=B.C}&quot;</span> <span style="color: #339933;">/&gt;</span>
  <span style="color: #339933;">&lt;</span>TextBox Text<span style="color: #009900;">&#123;</span>Binding Path<span style="color: #339933;">=</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#40;</span>x<span style="color: #339933;">:</span>int32<span style="color: #009900;">&#41;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span><span style="color: #0000ff;">&quot; /&gt;</span></pre></td></tr></table></div>

<p><br class="spacer_" /></p>
<h2>Custom Speller Dictionary  </h2>
<p>Ermöglicht anhand von eigenen Dictionaries eine Rechtschreibprüfung </p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>RichTextBox FontSize<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;24&quot;</span> SpellCheck<span style="color: #339933;">.</span>IsEnabled<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;true&quot;</span> <span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>SpellCheck<span style="color: #339933;">.</span>CustomDictionaries<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>sys<span style="color: #339933;">:</span>Uri<span style="color: #339933;">&gt;</span>Dictionary1<span style="color: #339933;">.</span>lex<span style="color: #339933;">&lt;/</span>sys Uri<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>sys1<span style="color: #339933;">:</span>Uri<span style="color: #339933;">&gt;</span>\\dictServer\Dictionary3<span style="color: #339933;">.</span>txt<span style="color: #339933;">&lt;/</span>sys1<span style="color: #339933;">:</span>Uri<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;/</span>SpellCheck<span style="color: #339933;">.</span>CustomDictionaries<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>FlowDocument<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>Paragraph<span style="color: #339933;">&gt;</span>Some Names<span style="color: #339933;">:</span> <span style="color: #990000;">Max</span> Musterman<span style="color: #339933;">&lt;/</span>Paragraph<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>Paragraph<span style="color: #339933;">&gt;</span>Misspelled<span style="color: #339933;">:</span> <span style="color: #990000;">Max</span> Mustermann<span style="color: #339933;">&lt;/</span>Paragrap<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;/</span>FlowDocument<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>RichTextBox<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p><br class="spacer_" /></p>
<h2>Windows7 API</h2>
<ul type="disc">
<li>System.Windows.Shell &#8211;      TaskBar </li>
<li>Ist das OS &lt; Windows7,      wird keine Exception ausgelöst </li>
<li>Einfacher Verwendung in Xaml </li>
<li>Window.TaskBarItemInfo </li>
<li>Overlay </li>
<li>ProgressState, ProgressValue </li>
<li>Xaml ThumbButtonInfo </li>
<li>Application.xaml Jumplist      JumpTask !! </li>
</ul>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>Window<span style="color: #339933;">.</span>TaskbarItemInfo<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>TaskbarItemlnfo Description<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;My TaskbarItemInfo Overlay=&quot;</span><span style="color: #339933;">..</span>\Resources\powerButton<span style="color: #339933;">.</span>ico<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>TaskbarItemlnfo<span style="color: #339933;">.</span>ThumbButtonInfos<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>ThumbButtonInfos Command<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Cut&quot;</span> CommandTarget<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;{Binding Elementname=textBox} Description=&quot;</span><span style="color: #009900;">&#40;</span>Binding RelativeSource<span style="color: #339933;">=</span><span style="color: #009900;">&#123;</span>RelativeSource <span style="color: #000000; font-weight: bold;">Self</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> Path<span style="color: #339933;">=</span>Command<span style="color: #339933;">.</span>Text<span style="color: #009900;">&#125;</span><span style="color: #0000ff;">&quot; DismissWhenClicked=&quot;</span><span style="color: #009900; font-weight: bold;">False</span><span style="color: #0000ff;">&quot; ImageSource=&quot;</span><span style="color: #339933;">..</span>\Resources\cut<span style="color: #339933;">.</span>png<span style="color: #0000ff;">&quot; /&gt;</span></pre></td></tr></table></div>

<p><br class="spacer_" /></p>
<h2>XBAP Script Interop / Full Trust XBAP Deployment</h2>
<p>Via Assemblyeinstellung ist es möglich aus der Sandbox heraus zu kommen und auf das System zuzugreifen. Applikationen wie Excel lassen sich so aus XBAP heraus öffnen und bearbeiten.</p>
<p><a href="http://www.biggle.de/blog/wp-content/uploads/2010/03/trustedxbap.png"><img class="alignnone size-full wp-image-4127" title="trustedxbap" src="http://www.biggle.de/blog/wp-content/uploads/2010/03/trustedxbap.png" alt="" width="360" height="174" /></a></p>
<p><br class="spacer_" /></p>
<h2>FileDialog Update</h2>
<p>In der vorherigen Version, sah das Design der DialogBox unter XP und Vista unterschiedlich aus. Durch einige Workarounds konnte man das abgleichen. In der Version 4.0 wurde dieses Problem nun behoben.</p>
<p><br class="spacer_" /></p>
<h2>XAML Neuerungen</h2>
<ul type="disc">
<li>x:Arguments </li>
<li>x:FactoryMethod </li>
<li>x:Reference (anstatt Binding      ElementName) </li>
</ul>
<hr /><p style="float:right; font-size:0.9em;">Dieser Beitrag stammt von <a href="http://www.biggle.de">Mario Priebe</a>.</p><h2  class="related_post_title">Ähnliche Beiträge</h2><ul class="related_post"><li>12. März 2010 -- <a href="http://www.biggle.de/blog/named-optional-arguments-covariance-contravariance-dynamic-und-com-interop" title="Named &#038; Optional Arguments, Co- &#038; Contravariance, Dynamic und COM Interop">Named &#038; Optional Arguments, Co- &#038; Contravariance, Dynamic und COM Interop</a></li><li>15. März 2010 -- <a href="http://www.biggle.de/blog/expression-blend-4-0-beta" title="Expression Blend 4.0 Beta">Expression Blend 4.0 Beta</a></li><li>12. März 2010 -- <a href="http://www.biggle.de/blog/neuerungen-in-visual-studio-2010" title="Neuerungen in Visual Studio 2010">Neuerungen in Visual Studio 2010</a></li><li>12. März 2010 -- <a href="http://www.biggle.de/blog/weitere-neuerungen-veraenderungen-im-net-framework-4-0" title="Weitere Neuerungen im .NET Framework 4.0">Weitere Neuerungen im .NET Framework 4.0</a></li><li>12. März 2010 -- <a href="http://www.biggle.de/blog/parallele-programmierung-mit-net-4-0" title="Parallele Programmierung mit .NET 4.0">Parallele Programmierung mit .NET 4.0</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.biggle.de/blog/neues-in-wpf-4/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Neuerungen in Visual Studio 2010</title>
		<link>http://www.biggle.de/blog/neuerungen-in-visual-studio-2010</link>
		<comments>http://www.biggle.de/blog/neuerungen-in-visual-studio-2010#comments</comments>
		<pubDate>Fri, 12 Mar 2010 09:48:11 +0000</pubDate>
		<dc:creator>Mario Priebe</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[CSharp]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[.NET4.0]]></category>
		<category><![CDATA[Basta]]></category>
		<category><![CDATA[VisualStudio]]></category>

		<guid isPermaLink="false">http://www.biggle.de/blog/?p=4104</guid>
		<description><![CDATA[Ich hab kürzlich die BASTA Spring 2010 besucht (über 500 Teilnehmer). Es war wirklich eine sehr informative Veranstaltung über aktuelle Entwicklungen im .NET Bereich. Folgender Abriss soll die Neuerungen im .NET Framework 4.0, Entity Framework 2, VisualStudio 2010, WPF 4 und Silverlight 4, aufzeigen. Im folgenden Artikel möchte ich über einige Neuerungen in Visual Studio [...]]]></description>
			<content:encoded><![CDATA[<p>Ich hab kürzlich die BASTA Spring 2010 besucht (über 500 Teilnehmer). Es war wirklich eine sehr informative Veranstaltung über aktuelle Entwicklungen im .NET Bereich. Folgender Abriss soll die Neuerungen im .NET Framework 4.0, Entity Framework 2, VisualStudio 2010, WPF 4 und Silverlight 4, aufzeigen.</p>
<p><a href="http://www.biggle.de/blog/wp-content/uploads/2010/03/bastalogo13.jpg"><img src="http://www.biggle.de/blog/wp-content/uploads/2010/03/bastalogo13.jpg" alt="" title="bastalogo1" width="500" height="77" class="alignnone size-full wp-image-4119" /></a></p>
<p>Im folgenden Artikel möchte ich über einige Neuerungen in Visual Studio 2010 schreiben</p>
<p>Zu Beginn eine  Übersicht, welche Komponenten in welcher Version enthalten sein werden:</p>
<p><a href="http://www.biggle.de/blog/wp-content/uploads/2010/03/visualStudio2010versionen.png"><img class="alignnone size-full wp-image-4105" title="visualStudio2010versionen" src="http://www.biggle.de/blog/wp-content/uploads/2010/03/visualStudio2010versionen.png" alt="" width="500" height="337" /></a></p>
<p><br class="spacer_" /></p>
<h2>WPF basierter Editor</h2>
<p>Der Editor in VisualStudio 2010 ist komplett in WPF umgesetzt.</p>
<p><br class="spacer_" /></p>
<h2>MultiMonitor Unterstützung</h2>
<p>Für alle Fenster wird der Multimonitorbetrieb unterstützt</p>
<p><br class="spacer_" /></p>
<h2>Stufenloser Zoom</h2>
<p>Mit STRG &#8211; Mausrad kann der Code vergrößert werden</p>
<p><br class="spacer_" /></p>
<h2>Navigation</h2>
<ul type="disc">
<li>Quick Search </li>
<li>Highlight References </li>
</ul>
<p><br class="spacer_" /></p>
<h2>UML Designer (UltimateVersion)</h2>
<ul type="disc">
<li>Die Ultimate Edition von      Visual Studio unterstützt die Modellierung mit UML (use-case-, class-,      sequence-, activity- und componentdiagramme) </li>
<li>Beinhaltet eine      Code-Generierung (T4-TextTemplate) für C# und Visual Basic </li>
<li>Beinhaltet eine Datenbank      Script-Generierung </li>
</ul>
<p>Quelle: <a href="http://www.olegsych.com/2010/01/uml-modeling-and-code-generation-in-visual-studio-2010/">http://www.olegsych.com/2010/01/uml-modeling-and-code-generation-in-visual-studio-2010/</a></p>
<p><br class="spacer_" /></p>
<h2>Debugging</h2>
<p>Mit den neuen Funktionen von VS2010 können Windows-, Web, .NETbasierende Anwendungen effizienter und komfortabel, sowohl in virtuellen als auch in echten 32- und 64Bit Umgebungen, getestet werden.</p>
<p><br class="spacer_" /></p>
<h3>Pin to Source</h3>
<p>Mit Pin2Source kann man aus dem KontextMenu heraus die entsprechende Variable oder Abschnitt im QuellText &#8220;anpinnen&#8221;:</p>
<p><a href="http://www.biggle.de/blog/wp-content/uploads/2010/03/pin2source.png"><img class="alignnone size-full wp-image-4106" title="pin2source" src="http://www.biggle.de/blog/wp-content/uploads/2010/03/pin2source.png" alt="" width="500" /></a></p>
<p><a href="http://www.biggle.de/blog/wp-content/uploads/2010/03/pin2source2.png"><img class="alignnone size-full wp-image-4107" title="pin2source2" src="http://www.biggle.de/blog/wp-content/uploads/2010/03/pin2source2.png" alt="" width="500" /></a></p>
<p><a href="http://www.biggle.de/blog/wp-content/uploads/2010/03/pin2source3.png"><img class="alignnone size-full wp-image-4108" title="pin2source3" src="http://www.biggle.de/blog/wp-content/uploads/2010/03/pin2source3.png" alt="" width="500" /></a></p>
<p><br class="spacer_" /></p>
<h2>Tracepoints, Breakpoints, Conditionals</h2>
<h3>TracePoints</h3>
<p>Im KontextMenü des Editors findet man den Punkt &#8220;Insert Tracepoint&#8221;. TracePoints sind eine Erweiterung der Breakpoints und erlauben es, das Erreichen einer Ausführungszeile mit einer Aktion zu verknüpfen.</p>
<p>Tracepoints kann man beispielsweise zur Ausgabe von Variablenwerten im Ausgabefenster nutzen und so Konstrukte wie Console.WriteLine und die TraceKlasse ablösen – ohne einen Eingriff in den Quelltext!</p>
<p>Angenommen in folgender Schleife ist man an einen Increment interessiert und möchte laufend dessen Wert ausgeben:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">var</span> x <span style="color: #339933;">=</span> i<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Man klickt hier mit der rechten Maustaste auf die zweite Zeile und wählt im Kontextmenü Breakpoint > Insert Tracepoint. Im folgenden Dialog kann man den Tracepoint konfigurieren und für diesen folgende Ausgabe definieren:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">i ist <span style="color: #009900;">&#123;</span>i<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Während der Debug-Sitzung wird im Ausgabefenster nun einhundert Mal der Wert von i gelistet.</p>
<p>Tracepoints können aber noch mehr.</p>
<ul type="disc">
<li>Tracepoints können zusätzlich      wie ein normaler Breakpoint verwendet werden, wenn die Option Continue      execution deaktiviert wird. </li>
<li>Die Ausgabe kann mittels      weiterer Platzhalter wie {$FUNC} um sinnvolle Informationen erweitert      werden. </li>
<li>Beim Erreichen eines      Tracepoints kann man ein VisualStudio Makro auslösen. </li>
</ul>
<p><br class="spacer_" /></p>
<h3>BreakPoints</h3>
<ul type="disc">
<li>Breakpoint labeln und Export      aller Breakpoints </li>
<li>Breakpoints können per Drag      &amp; Drop heraus gezogen werden </li>
<li>Breakpoint-Pakete können      verschickt werden </li>
<li>Breakpoints im Code      definieren, nicht commiten : ) </li>
<li>Breakpoint Gruppen </li>
<li>Tools/Options/Debugging/General      Enable Just my Code ausstellen </li>
<li>CTRL &#8211; B setzt Breakpoint auf      beliebige Funktion (use intellisense aus) werden im Tree angezeigt      (Breakpoints) </li>
</ul>
<p><br class="spacer_" /></p>
<p>Webcast:</p>
<ul type="disc">
<li>Breakpoint      exportieren <a href="http://channel9.msdn.com/posts/Dariusz/VS-2010-Quick-Hit-Exportable-Breakpoints/">[1]</a> </li>
</ul>
<p><br class="spacer_" /></p>
<h3>Conditionals</h3>
<ul type="disc">
<li>Rechtsklick auf Breakpoint </li>
<li>(condition) In C# definieren </li>
<li>When hit: kann makro      ausführen… oder nur print , Anwendung bleibt nicht stehen </li>
</ul>
<p><br class="spacer_" /></p>
<h3>IntelliTrace</h3>
<p>Mit IntelliTrace reproduzierbare Fehler finden (Ultimate) IntelliTrace sammelt Informationen, die helfen die Fehlersuche und -diagnose zu vereinfachen und verbessert so die Produktivität beim Debugging. Aus der IntelliTrace Daten kann die Test-Session auf einem Entwickler-Rechner wiederhergestellt und die Fehler somit reproduziert werden.</p>
<ul type="disc">
<li>Wie kann man Probleme      debuggen, die nur beim Kunden auftreten </li>
<li>DumpDebugging </li>
<li>Prozesse save as dump </li>
<li>Kann sich selbst dumpen </li>
<li>File kann debugged werden </li>
<li>Alle Threads inkl aller  Variablen sind dort enthalten </li>
<li>*.DMP in vs2010 öffnen zeigt Exceptions und den StackTrace </li>
<li>IntelliTrace hilft beim Debugging von nichtreproduzierbaren Fehlern beim Tester ohne VS </li>
<li>TraceDebuggerTools beinhaltet  IntellTrace </li>
<li>collectionPlan.xml </li>
<li>Das entsprechende File kann dann mit IntelliTrace überprüft werden </li>
<li>Beinhaltet einen ASP.NET Client Proxy für IntelliTrace der Informationen über http-Aufrufe vom      Client zum Webserver sammelt. </li>
</ul>
<p>IntelliTrace muss in den Optionen > IntelliTrace aktiviert und konfiguriert werden</p>
<p>(IntelliTrace unter 64bit nicht möglich (auf x86 stellen))</p>
<p><br class="spacer_" /></p>
<h3>Debugger Attributes</h3>
<p>Im Namensraum System.Diagnostics gibt es eine Reihe von Attributen, die angewandt auf eigene Klassen das Verhalten des Debuggers beeinflussen können. Die Attribute werden für Klassen, Methoden oder Eigenschaften definiert.</p>
<p>Mit DebuggerBrowsableAttribute legt man fest, ob und wie eine Eigenschaft oder ein Feld in den verschiedenen Debugger- Fenstern (Locals, Autos, ..) angezeigt wird. Über die Enumeration DebuggerBrowsableState kann man einen der folgenden Werte wählen:</p>
<ul type="disc">
<li>Never = keine Anzeige, </li>
<li>Collapsed = Anzeige, </li>
<li>RootHidden = Anzeige der      Unterelemente, beispielsweise eines Arrays. </li>
</ul>
<p><br class="spacer_" /></p>
<h3>DebuggerDisplay</h3>
<p>Wird auf Klassenebene deklariert und legt fest, welche Informationen aus der Klasse in den DebuggingFenstern angezeigt werden sollen.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009900;">&#91;</span>DebuggerDisplay<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Kunde -  {FirstName}  {LastName}&quot;</span><span style="color: #009900;">&#93;</span></pre></div></div>

<p><br class="spacer_" /></p>
<h3>DebuggerVisualizer</h3>
<p>Wenn man noch mehr Möglichkeiten sucht, um einen Datentyp zu visualisieren, verwendet man das Attribute DebuggerVisualizer. Damit ist beispielsweise möglich, bei einem Datentyp Image sich dieses in Visual Studio anzeigen zu lassen.</p>
<p><br class="spacer_" /></p>
<h3>Debuggingrechte in Visual Studio</h3>
<p>Mit den Attributen DebuggerHidden, DebuggerStepperBoundary, DebuggerNonUserCode und DebuggerStepTrough lässt es sich festlegen, ob und wie VS das Debuggen einer Klasse oder einer Methode erlaubt.</p>
<p><br class="spacer_" /></p>
<h3>Thread Debugging</h3>
<ul type="disc">
<li>Debugging von mehreren      Threads (muss aktiviert werden) </li>
<li>Icon Diagramm rot grün + aktivieren </li>
<li>Rechtsklick flag, flagt den      entsprechenden Thread </li>
<li>Freeze kann alle Threads      anhalten, ein gezielter kann wieder aktiviert werden </li>
</ul>
<p><br class="spacer_" /></p>
<h3>Edit and continue</h3>
<p>Hier handelt es sich um ein Feature, das es einem ermöglicht &#8211; wie schon lange in Visual Basic &#8211; im DebuggingModus Änderungen am Quelltext vorzunehmen und ohne Neuzukompilieren diese zu übernehmen.</p>
<p>Das Feature kann unter Optionen > Debugging > Edit and Continue aktiviert werden</p>
<p>(Edit &amp; Continue funktioniert nicht, wenn IntelliTrace aktiviert ist)</p>
<p><br class="spacer_" /></p>
<h2>Entity Framework 2</h2>
<ul type="disc">
<li>Model First Development      (Generate DataBase from Model) </li>
<li>Create the database from code      (no model needed) </li>
<li>Ermöglicht das Generieren der      Datenbank aus dem Modell -und- auch aus dem Code heraus. </li>
</ul>
<p><a href="http://www.biggle.de/blog/wp-content/uploads/2010/03/ef2.png"><img class="alignnone size-full wp-image-4109" title="ef2" src="http://www.biggle.de/blog/wp-content/uploads/2010/03/ef2.png" alt="" width="452" height="239" /></a></p>
<p><br class="spacer_" /></p>
<h3>Automatic Pluralization</h3>
<p>Bietet eine Pluralisierung an. EF würde in dem Fall an jeder Entität ein &#8220;s&#8221; anzuhängen. &#8230;</p>
<p><br class="spacer_" /></p>
<h3>Foreign Keys in Models</h3>
<p>Man kann Fremdschlüssel im Model verwenden, dazu beim Erstellen Include foreign key columns in the model aktivieren.</p>
<p><a href="http://www.biggle.de/blog/wp-content/uploads/2010/03/ef2vsef1.png"><img class="alignnone size-full wp-image-4111" title="ef2vsef1" src="http://www.biggle.de/blog/wp-content/uploads/2010/03/ef2vsef1.png" alt="" width="250" height="353" /></a></p>
<h3>Lazy Loading</h3>
<p>Der EF-Assistenten erzeugt enumerierbare Eigenschaften für jeden ForeignKey, den er auf einer Tabelle findet. Ein &#8220;Include&#8221; erzeugt innerhalb einer EF-Abfrage einen Join und bindet somit die Daten der verknüpften Tabelle mit ein. Diese Technik wird Eager Loading genannt und sorgt dafür das immer alle Daten im Join sind.</p>
<p>Das ist natürlich meist das Gegenteil, was man erreichen will, denn man möchte Daten erst dann von der Datenbank laden, wenn man sie auch benötigt.</p>
<p>Im Unterschied zur Nutzung von Include direkt auf der Entitäten-Menge Orders (ctx.Orders.Include(&#8220;Customers&#8221;)) kann das Load nun gezielt auf einzelne Order-Entitäten bei Bedarf erfolgen:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">using <span style="color: #009900;">&#40;</span>NorthwindEntities ctx <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> NorthwindEntities<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span>Orders orders in ctx<span style="color: #339933;">.</span>Orders<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        orders<span style="color: #339933;">.</span>CustomersReference<span style="color: #339933;">.</span>Load<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        Console<span style="color: #339933;">.</span>WriteLine<span style="color: #009900;">&#40;</span>orders<span style="color: #339933;">.</span>Customers<span style="color: #339933;">.</span>ContactName<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<h3>Lazy Loading auf Feldebene</h3>
<p>Fast noch wichtiger als das Lazy Loading auf Mengen-Ebene ist die Steuerung des Ladeverhaltens einer einzelnen Entität. Nehmen wir an, wir benötigen nur zwei Spalten aus der Customer Tabelle, um eine ComboBox mit den Spalten CustomerID und CompanyName zu binden. Im folgenden Code nutzen wir zunächst die scheinbar einfache Methode:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">using <span style="color: #009900;">&#40;</span>NorthwindEntities ctx <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> NorthwindEntities<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    BindingSource bs <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> BindingSource<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    bs<span style="color: #339933;">.</span>DataSource <span style="color: #339933;">=</span> ctx<span style="color: #339933;">.</span>Customers<span style="color: #339933;">;</span>
    cbCustomers<span style="color: #339933;">.</span>ValueMember <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;CustomerID&quot;</span><span style="color: #339933;">;</span>
    cbCustomers<span style="color: #339933;">.</span>DisplayMember <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;CompanyName&quot;</span><span style="color: #339933;">;</span>
    cbCustomers<span style="color: #339933;">.</span>DataSource <span style="color: #339933;">=</span> bs<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Also auf den ersten Blick scheint alles gut. Aber wie sieht es denn hinter den Kulissen aus, Das geschickte SQL-Kommando:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">SELECT
 <span style="color: #009900;">&#91;</span>Extent1<span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #009900;">&#91;</span>CustomerID<span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">AS</span> <span style="color: #009900;">&#91;</span>CustomerID<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
 <span style="color: #009900;">&#91;</span>Extent1<span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #009900;">&#91;</span>CompanyName<span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">AS</span> <span style="color: #009900;">&#91;</span>CompanyName<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
 <span style="color: #009900;">&#91;</span>Extent1<span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #009900;">&#91;</span>ContactName<span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">AS</span> <span style="color: #009900;">&#91;</span>ContactName<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
 <span style="color: #009900;">&#91;</span>Extent1<span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #009900;">&#91;</span>ContactTitle<span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">AS</span> <span style="color: #009900;">&#91;</span>ContactTitle<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
 <span style="color: #009900;">&#91;</span>Extent1<span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #009900;">&#91;</span>Address<span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">AS</span> <span style="color: #009900;">&#91;</span>Address<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
 <span style="color: #009900;">&#91;</span>Extent1<span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #009900;">&#91;</span>City<span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">AS</span> <span style="color: #009900;">&#91;</span>City<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
 <span style="color: #009900;">&#91;</span>Extent1<span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #009900;">&#91;</span>Region<span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">AS</span> <span style="color: #009900;">&#91;</span>Region<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
 <span style="color: #009900;">&#91;</span>Extent1<span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #009900;">&#91;</span>PostalCode<span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">AS</span> <span style="color: #009900;">&#91;</span>PostalCode<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
 <span style="color: #009900;">&#91;</span>Extent1<span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #009900;">&#91;</span>Country<span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">AS</span> <span style="color: #009900;">&#91;</span>Country<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
 <span style="color: #009900;">&#91;</span>Extent1<span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #009900;">&#91;</span>Phone<span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">AS</span> <span style="color: #009900;">&#91;</span>Phone<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
 <span style="color: #009900;">&#91;</span>Extent1<span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #009900;">&#91;</span>Fax<span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">AS</span> <span style="color: #009900;">&#91;</span>Fax<span style="color: #009900;">&#93;</span>
 FROM <span style="color: #009900;">&#91;</span>dbo<span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #009900;">&#91;</span>Customers<span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">AS</span> <span style="color: #009900;">&#91;</span>Extent1<span style="color: #009900;">&#93;</span></pre></td></tr></table></div>

<p>Wir fragen also die komplette Tabelle Customers ab, nur um 2 Spalten anzuzeigen bzw. zu nutzen?! Das widerspricht also jeglicher Vernunft. In EF kann man dies durch die Rückgabe anonymer Typen über LINQ lösen:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">using <span style="color: #009900;">&#40;</span>NorthwindEntities ctx <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> NorthwindEntities<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">var</span> customers <span style="color: #339933;">=</span> from c in ctx<span style="color: #339933;">.</span>Customers
                  select <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #009900;">&#123;</span> c<span style="color: #339933;">.</span>CustomerID<span style="color: #339933;">,</span> c<span style="color: #339933;">.</span>CompanyName <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    cboCustomers<span style="color: #339933;">.</span>DataSource <span style="color: #339933;">=</span> customers<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Dieses SQL Kommando dagegen lässt sich dann schon sehen </p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">SELECT
<span style="color: #cc66cc;">1</span> <span style="color: #b1b100;">AS</span> <span style="color: #009900;">&#91;</span>C1<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#91;</span>Extent1<span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #009900;">&#91;</span>CustomerID<span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">AS</span> <span style="color: #009900;">&#91;</span>CustomerID<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#91;</span>Extent1<span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #009900;">&#91;</span>CompanyName<span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">AS</span> <span style="color: #009900;">&#91;</span>CompanyName<span style="color: #009900;">&#93;</span>
FROM <span style="color: #009900;">&#91;</span>dbo<span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #009900;">&#91;</span>Customers<span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">AS</span> <span style="color: #009900;">&#91;</span>Extent1<span style="color: #009900;">&#93;</span></pre></td></tr></table></div>

<h3>More LINQ operator Support</h3>
<p>.Single(), SingleOrDefault(); &#8230;</p>
<p><br class="spacer_" /></p>
<h3>EF1 vs. EF 2</h3>
<p>Neuer Designer</p>
<ul type="disc">
<li>Unterstützung von      POCO </li>
<li>Unterstützung von .tt      Vorlagen </li>
<li>Unterstützung von      Pluralisierung und Singularisierung </li>
<li>Fremdschlüssel </li>
<li>Model First Unterstützung </li>
<li>Lazy Loading Unterstützung </li>
<li>Missing LINQ Operators </li>
<li>Generated SQL unlesbar </li>
<li>N-Tier schwer </li>
<li>Bessere Unterstützung von      Stored Procedures </li>
</ul>
<p><br class="spacer_" /></p>
<h2>Workflow Foundation 4.0</h2>
<ul type="disc">
<li>Komplette Neuimplementierung      der WF in Version 4.0 </li>
<li>Mit Flowchart modellieren </li>
<li>Keine State-Machine mehr </li>
<li>Custom Activities </li>
<li>Kombinieren von WCF und WF </li>
<li>Base Activity Library </li>
<li>BPEL </li>
<li>Utilities </li>
<li>Expressions </li>
<li>Error handling </li>
<li>WCF Messaging </li>
<li>DataBase </li>
<li>WF Primitives </li>
<li>PowerShell </li>
<li>Interop </li>
<li>Control Flow Activities </li>
<li>Flowcharts </li>
<li>Sequential </li>
<li>Rules </li>
<li>Webcasts: </li>
<li><a href="http://www.cloudcasts.net/Default.aspx?category=WCF%20WF%204.0">http://www.cloudcasts.net/Default.aspx?category=WCF%20WF%204.0</a> </li>
<li><a href="http://channel9.msdn.com/pdc2008/TL17/">http://channel9.msdn.com/pdc2008/TL17/</a> </li>
<li><a href="http://www.microsoft.com/germany/msdn/webcasts/library.aspx?id=1032437931">http://www.microsoft.com/germany/msdn/webcasts/library.aspx?id=1032437931</a> </li>
<li><a href="http://www.microsoft.com/germany/msdn/webcasts/library.aspx?id=1032437932">http://www.microsoft.com/germany/msdn/webcasts/library.aspx?id=1032437932</a> </li>
<li><a href="http://msdn.microsoft.com/de-de/wf-screencasts.aspx">http://msdn.microsoft.com/de-de/wf-screencasts.aspx</a> </li>
<li>First WorkFlow <a href="http://mschnlnine.vo.llnwd.net/d1/ch9/8/5/4/6/2/4/WF_SeqWF.wmv">http://mschnlnine.vo.llnwd.net/d1/ch9/8/5/4/6/2/4/WF_SeqWF.wmv</a> </li>
<li>Google Suche <a href="http://www.google.de/search?hl=en&amp;rlz=1B3GGGL_enDE354DE354&amp;q=workflow+foundation+4.0+filetype%3Awmv&amp;btnG=Search&amp;aq=f&amp;oq=">http://www.google.de/search?hl=en&amp;rlz=1B3GGGL_enDE354DE354&amp;q=workflow+foundation+4.0+filetype%3Awmv&amp;btnG=Search&amp;aq=f&amp;oq=</a> </li>
<li>Quellen: </li>
<li><a href="http://msdn.microsoft.com/en-us/netframework/aa663328.aspx">http://msdn.microsoft.com/en-us/netframework/aa663328.aspx</a> </li>
<li>Überblick <a href="http://msdn.microsoft.com/de-de/netframework/cc896557.aspx">http://msdn.microsoft.com/de-de/netframework/cc896557.aspx</a> </li>
<li>Beginners Guide <a href="http://channel9.msdn.com/shows/Endpoint/Endpoint-Screencasts-Creating-Your-First-Sequential-Workflow/">http://channel9.msdn.com/shows/Endpoint/Endpoint-Screencasts-Creating-Your-First-Sequential-Workflow/</a> </li>
<li>WF Scenarios      Guidance: <a href="http://msdn.microsoft.com/de-de/library/ee373755%28en-us%29.aspx">http://msdn.microsoft.com/de-de/library/ee373755%28en-us%29.aspx</a></li>
</ul>
<p><br class="spacer_" /></p>
<h2>F#</h2>
<p>Nach dem Start von J# nun ein erneuter Versuch unter den Namen F# eine Funktionale Sprache die sie nur auf das wesentliche für Mathematiker beschränken soll.</p>
<p><br class="spacer_" /></p>
<h2>Add-Ons</h2>
<p>Für das Installieren eines Addon ist nur noch das Kopieren notwendig (nicht mehr über die Registry).</p>
<p><br class="spacer_" /></p>
<h2>Architektur Explorer</h2>
<p>Ist ein integriertes Tool, das es ermöglicht die bestehende Architektur in einem Projekt oder einer binären Datei zu einen Modell zu erzeugen.</p>
<p><br class="spacer_" /></p>
<h2>Tipps &amp; Tricks in VS2010</h2>
<ul type="disc">
<li>Call Hierarchy CTRL + K, T </li>
<li>IntelliSense Suggestion Mode      (vs. Completion Mode) CTRL + ALT + Space </li>
</ul>
<p><br class="spacer_" /></p>
<h2>Visual Studio 2010 Web Frameworks</h2>
<ul type="disc">
<li>ASP.NET WebForms 4 </li>
<li>Neue Vorlagen mit Masterpages      und Stylesheets </li>
<li>Neues Routingmodell </li>
<li>ASP.NET MVC 4 </li>
<li>Komplett neue      Herangehensweise an Webseiten </li>
<li>Neues Modell, parallel zum      WebForms Modell </li>
<li>Schwerpunkt: Testbarkeit </li>
<li>ASP.NET Ajax 4 </li>
<li>Windows Azure SDK &amp; Tools </li>
<li>Dynamic Data </li>
<li>.NET RIA Services </li>
</ul>
<p><br class="spacer_" /></p>
<p>Im nächsten Artikel schreibe ich über einige Neuerungen in WPF 4.0</p>
<p><br class="spacer_" /></p>
<hr /><p style="float:right; font-size:0.9em;">Dieser Beitrag stammt von <a href="http://www.biggle.de">Mario Priebe</a>.</p><h2  class="related_post_title">Ähnliche Beiträge</h2><ul class="related_post"><li>12. März 2010 -- <a href="http://www.biggle.de/blog/weitere-neuerungen-veraenderungen-im-net-framework-4-0" title="Weitere Neuerungen im .NET Framework 4.0">Weitere Neuerungen im .NET Framework 4.0</a></li><li>12. März 2010 -- <a href="http://www.biggle.de/blog/parallele-programmierung-mit-net-4-0" title="Parallele Programmierung mit .NET 4.0">Parallele Programmierung mit .NET 4.0</a></li><li>12. März 2010 -- <a href="http://www.biggle.de/blog/named-optional-arguments-covariance-contravariance-dynamic-und-com-interop" title="Named &#038; Optional Arguments, Co- &#038; Contravariance, Dynamic und COM Interop">Named &#038; Optional Arguments, Co- &#038; Contravariance, Dynamic und COM Interop</a></li><li>11. Februar 2010 -- <a href="http://www.biggle.de/blog/visual-studio-2010-die-unterschiede" title="Visual Studio 2010 &#8211; Die Unterschiede">Visual Studio 2010 &#8211; Die Unterschiede</a></li><li>11. August 2010 -- <a href="http://www.biggle.de/blog/design-switching-crash-visual-studio-2010-hotfix" title="Design Switching Crash &#8211; Visual Studio 2010 Hotfix">Design Switching Crash &#8211; Visual Studio 2010 Hotfix</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.biggle.de/blog/neuerungen-in-visual-studio-2010/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://mschnlnine.vo.llnwd.net/d1/ch9/8/5/4/6/2/4/WF_SeqWF.wmv" length="19840473" type="video/x-ms-wmv" />
		</item>
		<item>
		<title>Weitere Neuerungen im .NET Framework 4.0</title>
		<link>http://www.biggle.de/blog/weitere-neuerungen-veraenderungen-im-net-framework-4-0</link>
		<comments>http://www.biggle.de/blog/weitere-neuerungen-veraenderungen-im-net-framework-4-0#comments</comments>
		<pubDate>Fri, 12 Mar 2010 09:03:21 +0000</pubDate>
		<dc:creator>Mario Priebe</dc:creator>
				<category><![CDATA[CSharp]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[.NET4.0]]></category>
		<category><![CDATA[Basta]]></category>

		<guid isPermaLink="false">http://www.biggle.de/blog/?p=4090</guid>
		<description><![CDATA[Ich hab kürzlich die BASTA Spring 2010 besucht (über 500 Teilnehmer). Es war wirklich eine sehr informative Veranstaltung über aktuelle Entwicklungen im .NET Bereich. Folgender Abriss soll die Neuerungen im .NET Framework 4.0, Entity Framework 2, VisualStudio 2010, WPF 4 und Silverlight 4, aufzeigen. Im folgenden Artikel möchte ich über weitere kleine Neuerungen und Veränderungen [...]]]></description>
			<content:encoded><![CDATA[<p>Ich hab kürzlich die BASTA Spring 2010 besucht (über 500 Teilnehmer). Es war wirklich eine sehr informative Veranstaltung über aktuelle Entwicklungen im .NET Bereich. Folgender Abriss soll die Neuerungen im .NET Framework 4.0, Entity Framework 2, VisualStudio 2010, WPF 4 und Silverlight 4, aufzeigen.</p>
<p><a href="http://www.biggle.de/blog/wp-content/uploads/2010/03/bastalogo12.jpg"><img class="alignnone size-full wp-image-4091" title="bastalogo1" src="http://www.biggle.de/blog/wp-content/uploads/2010/03/bastalogo12.jpg" alt="" width="500" height="77" /></a></p>
<p>Im folgenden Artikel möchte ich über weitere kleine Neuerungen und Veränderungen im .NET 4.0 Framework  schreiben:</p>
<p><br class="spacer_" /></p>
<h2>GarbageCollection</h2>
<p>Komplette Überarbeitung des GC, der GC unterstützt Background GarbageCollection Dieser ersetzt gleichzeitig die bisherigen Versionen und soll auch perfomanter sein.</p>
<ul type="disc">
<li>So whats new in  CLR 4.0 GC <a href="http://blogs.msdn.com/maoni/archive/2008/11/19/so-what-s-new-in-the-clr-4-0-gc.aspx">[1]</a></li>
</ul>
<p><br class="spacer_" /></p>
<h2>Code Contracts</h2>
<p>System.Diagnostics.Contracts</p>
<ul type="disc">
<li>MSDN <a href="http://msdn.microsoft.com/en-us/library/dd264808%28v=VS.100%29.aspx">[2]</a></li>
</ul>
<p><br class="spacer_" /></p>
<h2>Design-Time-only Interop-Assemblies</h2>
<p>Man benötigt nicht mehr die primary interop assemblies (PIAs) in der Arbeit mit COM-Objekten. Für jede Interop Komponente wird nun eine eigene Assembly bereitgestellt.</p>
<ul type="disc">
<li>Embedding Type      Information from Microsoft Office Assemblies <a href="http://msdn.microsoft.com/en-us/library/ee317478%28v=VS.100%29.aspx">[3]</a></li>
</ul>
<p><br class="spacer_" /></p>
<h2>BigInteger und komplexe Zahlen</h2>
<p>Die neue Struktur System.Numerics.BigInteger unterstützt alle Standard Integer Operationen, einschließlich Bitmanipulation. Dieser kann aus jeder .NET Framework-Sprache verwendet werden. Zusätzlich verfügen einige der neuen .NET Framework-Sprachen (z. B. F# und IronPython) integrierte Unterstützung für diese Struktur.</p>
<p>Die neue System.Numerics.Complex Struktur stellt eine komplexe Zahl, die arithmetische und trigonometrische Funktionen mit komplexen Zahlen unterstützt dar.</p>
<ul type="disc">
<li>BigInterger      Structure <a href="http://msdn.microsoft.com/en-us/library/system.numerics.biginteger%28v=VS.100%29.aspx">[4]</a> </li>
<li>Complex Structure      <a href="http://msdn.microsoft.com/en-us/library/system.numerics.complex%28v=VS.100%29.aspx">[5]</a></li>
</ul>
<p><br class="spacer_" /></p>
<h2>Tupels</h2>
<p>Die .NET Framework 4 Beta 2 stellt die System.Tuple-Klasse zum Erstellen von Tupel-Objekten, die strukturierte Daten enthalten.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> primes <span style="color: #339933;">=</span> Tuple<span style="color: #339933;">.</span>Create<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">7</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">11</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">13</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">17</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">19</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<ul type="disc">
<li>MSDN <a href="http://msdn.microsoft.com/en-us/library/system.tuple%28v=VS.100%29.aspx">[6]</a></li>
</ul>
<p><br class="spacer_" /></p>
<h2>64-Bit-Betriebssysteme und Prozesse</h2>
<p>Man kann mit Environment.Is64BitOperatingSystem und Environment.Is64BitProcess 64Bit Betriebssysteme und Prozesse identifizieren.</p>
<p><br class="spacer_" /></p>
<h2>IsNullOrWhiteSpace</h2>
<p>Die neue String.IsNullOrWhiteSpace-Methode gibt an, ob eine Zeichenfolge null ist, leer ist oder nur aus einem Leerzeichen besteht.</p>
<p><br class="spacer_" /></p>
<h2>String.Concat&lt;T&gt;</h2>
<p>Die String.Concat&lt;T&gt;-Methode kann jedes Element in eine aufzählbaren Auflistung, ohne ein vorheriges Konvertieren der Elemente in Strings, miteinander verketten.</p>
<ul>
<li>MSDN <a href="http://msdn.microsoft.com/en-us/library/system.string.concat(v=VS.100).aspx">[7]</a></li>
</ul>
<p><br class="spacer_" /></p>
<h2>StringBuilder.Clear &#8211; Stopwatch.Restart</h2>
<p>Zwei neue benutzerfreundliche Methoden stehen zur Verfügung</p>
<ul>
<li>MSDN <a href="http://msdn.microsoft.com/en-us/library/system.text.stringbuilder.clear(v=VS.100).aspx">[8]</a></li>
<li>MSDN <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch.restart(v=VS.100).aspx">[9]</a></li>
</ul>
<p><br class="spacer_" /></p>
<h2>Enum.HasFlag</h2>
<p>Die neue Enum.HasFlag-Methode bestimmt, ob eine oder mehrere Bitfelder oder Flags in einen Enumerationswert festgelegt sind. Enum.TryParse&lt;TEnum&gt;-Methode gibt einen booleschen Wert zurück, der angibt, ob eine Zeichenfolge oder ein ganzer Wert erfolgreich analysiert werden konnte.</p>
<ul>
<li>MSDN<a href="http://msdn.microsoft.com/en-us/library/system.enum.hasflag(v=VS.100).aspx"> [10]</a></li>
</ul>
<p><br class="spacer_" /></p>
<h2>System.Environment.SpecialFolder</h2>
<p>Die System.Environment.SpecialFolder-Enumeration enthält mehrere neue Ordner.</p>
<ul>
<li>MSDN <a href="http://msdn.microsoft.com/en-us/library/system.environment.specialfolder(v=VS.100).aspx">[11]</a></li>
</ul>
<p><br class="spacer_" /></p>
<h2>Stream &#8211; CopyTo()</h2>
<p>Einen Stream problemlos in einen anderen mit der CopyTo() Methode in Klassen kopieren, die von System.IO.Stream-Klasse erben.</p>
<ul>
<li>MSDN <a href="http://msdn.microsoft.com/en-us/library/system.io.stream.copyto(v=VS.100).aspx">[12]</a></li>
</ul>
<p><br class="spacer_" /></p>
<h2>Path.Combine</h2>
<p>Mir der neuen Path.Combine Methodenüberladung können Dateipfade kombiniert werde.</p>
<ul>
<li>MSDN <a href="http://msdn.microsoft.com/en-us/library/system.io.path.combine(v=VS.100).aspx">[13]</a></li>
</ul>
<p><br class="spacer_" /></p>
<h2>System.IObservable&lt;T&gt; System.IObserver&lt;T&gt;</h2>
<p>Die neue System.IObservable&lt;T&gt; und System.IObserver&lt;T&gt; Schnittstellen und bieten einen allgemeinen Mechanismus für Push-basierte Benachrichtigungen</p>
<ul>
<li>MSDN <a href="http://msdn.microsoft.com/en-us/library/dd990377(v=VS.100).aspx">[14]</a></li>
<li>MSDN <a href="http://msdn.microsoft.com/en-us/library/dd783449(v=VS.100).aspx">[15]</a></li>
</ul>
<p><br class="spacer_" /></p>
<h2>System.IntPtr und System.UIntPtr</h2>
<p>Die System.IntPtr und System.UIntPtr Klassen unterstützen jetzt die Addition und Subtraktion Operatoren.</p>
<ul>
<li>MSDN <a href="http://msdn.microsoft.com/en-us/library/system.intptr(v=VS.100).aspx">[16]</a></li>
<li>MSDN<a href="http://msdn.microsoft.com/en-us/library/system.uintptr(v=VS.100).aspx">[17]</a></li>
</ul>
<p><br class="spacer_" /></p>
<h2>System.Lazy&lt;T&gt;</h2>
<p>Man kann mit System.Lazy&lt;T&gt; nun für alle benutzerdefinierten Typen eine verzögerte Initialisierung aktivieren.</p>
<ul>
<li>MSDN <a href="http://msdn.microsoft.com/en-us/library/dd642331(v=VS.100).aspx">[18]</a></li>
</ul>
<p><br class="spacer_" /></p>
<h2>System.Collections.Generic.SortedSet&lt;T&gt;</h2>
<p>Die neue System.Collections.Generic.SortedSet&lt;T&gt;-Klasse stellt eine self-balancing Struktur, die Daten nach Einfügen, Löschen und Suchen in sortierter Reihenfolge verwaltet. Diese Klasse implementiert die neue System.Collections.Generic.ISet&lt;T&gt;-Schnittstelle.</p>
<ul>
<li>MSDN <a href="http://msdn.microsoft.com/en-us/library/dd412070(v=VS.100).aspx">[19]</a></li>
</ul>
<p><br class="spacer_" /></p>
<h2>System.IO.Compression.DeflateStream und GZipStream</h2>
<p>Die Komprimierungsalgorithmen für die System.IO.Compression.DeflateStream und System.IO.Compression.GZipStream Klassen haben sich verbessert, sodass Daten, die bereits komprimiert sind, sich nicht noch mehr vergrößern. Die 4GB-Größenbeschränkung für das Komprimieren von Streams wurde auch entfernt.</p>
<ul>
<li>MSDN <a href="http://msdn.microsoft.com/en-us/library/system.io.compression.deflatestream(v=VS.100).aspx">[20]</a></li>
<li>MSDN <a href="http://msdn.microsoft.com/en-us/library/system.io.compression.gzipstream(v=VS.100).aspx">[21]</a></li>
</ul>
<p><br class="spacer_" /></p>
<h2>Thread.Yield</h2>
<p>Bewirkt das der aufrufende Thread die Ausführung an einen anderen Thread abgibt und auf den aktuellen Prozessor ausgfeührt werden kann.</p>
<p>Ein Thread kann das ihm zugeteilte Recht der Ausführung freiwillig abgeben, um anderen, auf die Ausführung wartenden Threads die Chance einzuräumen, aktiv zu werden. Dies wird mit dem Aufruf der Methode Thread.Yield() erreicht.</p>
<ul>
<li>MSDN <a href="http://msdn.microsoft.com/en-us/library/system.threading.thread.yield(v=VS.100).aspx">[22]</a></li>
</ul>
<p><br class="spacer_" /></p>
<h2>System.Guid</h2>
<p>Die System.Guid Strukture beinhaltet nun die Methoden TryParse() und TryParseExact().</p>
<ul>
<li>MSDN <a href="http://msdn.microsoft.com/en-us/library/system.guid.tryparse(v=VS.100).aspx">[23]</a></li>
<li>MSDN <a href="http://msdn.microsoft.com/en-us/library/system.guid.tryparseexact(v=VS.100).aspx">[24]</a></li>
</ul>
<p><br class="spacer_" /></p>
<h2>Registry</h2>
<p>Der Registrierungsschlüssel ist nicht mehr auf einer maximalen Länge von 255 Zeichen beschränkt.</p>
<p>Neue Microsoft.Win32.RegistryOptions-Enumeration, beinhaltet Volatile. Dieser bewirkt das der Schlüssel nur im Arbeitsspeicher gehalten wird und nach einem Neustart nicht mehr zur Verfügung steht. Dieses wird als flüchtiger Schlüssel bezeichnet.</p>
<ul>
<li>MSDN <a href="http://msdn.microsoft.com/en-us/library/microsoft.win32.registryoptions(v=VS.100).aspx">[25]</a></li>
</ul>
<p><br class="spacer_" /></p>
<h2>Obsolete Types</h2>
<p><a href="http://msdn.microsoft.com/en-us/library/ee461503%28VS.100%29.aspx">http://msdn.microsoft.com/en-us/library/ee461503%28VS.100%29.aspx</a></p>
<p><br class="spacer_" /></p>
<h2>Obsolete Member</h2>
<p><a href="http://msdn.microsoft.com/en-us/library/ee471421%28VS.100%29.aspx">http://msdn.microsoft.com/en-us/library/ee471421%28VS.100%29.aspx</a></p>
<p><br class="spacer_" /></p>
<h2>Kompatibilität TFS 2008 &#8211; TFS 2010</h2>
<p>Was geht und was geht nicht, ist <a href="http://blogs.msdn.com/teams_wit_tools/archive/2009/10/19/compatibility-matrix-for-2010-beta-2-team-foundation-server-to-team-explorer-2008-and-2005.aspx">hier</a> genau beschrieben.</p>
<p>Dennoch muss noch folgender Patch auf den Clients installiert werden: <a href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;FamilyID=cf13ea45-d17b-4edc-8e6c-6c5b208ec54d">Visual Studio Team System 2008 Service Pack 1 Forward Compatibility Update for Team Foundation Server 2010 (Installer)</a></p>
<p><br class="spacer_" /></p>
<p>Im nächsten Artikel schreibe ich über einige Neuerungen in Visual Studio 2010<br class="spacer_" /></p>
<hr /><p style="float:right; font-size:0.9em;">Dieser Beitrag stammt von <a href="http://www.biggle.de">Mario Priebe</a>.</p><h2  class="related_post_title">Ähnliche Beiträge</h2><ul class="related_post"><li>12. März 2010 -- <a href="http://www.biggle.de/blog/neuerungen-in-visual-studio-2010" title="Neuerungen in Visual Studio 2010">Neuerungen in Visual Studio 2010</a></li><li>12. März 2010 -- <a href="http://www.biggle.de/blog/parallele-programmierung-mit-net-4-0" title="Parallele Programmierung mit .NET 4.0">Parallele Programmierung mit .NET 4.0</a></li><li>12. März 2010 -- <a href="http://www.biggle.de/blog/named-optional-arguments-covariance-contravariance-dynamic-und-com-interop" title="Named &#038; Optional Arguments, Co- &#038; Contravariance, Dynamic und COM Interop">Named &#038; Optional Arguments, Co- &#038; Contravariance, Dynamic und COM Interop</a></li><li>25. Juli 2010 -- <a href="http://www.biggle.de/blog/dynamische-klasse-mit-dynamicobject-erstellen" title="Dynamische Klasse mit DynamicObject erstellen">Dynamische Klasse mit DynamicObject erstellen</a></li><li>12. März 2010 -- <a href="http://www.biggle.de/blog/neues-in-wpf-4" title="Neues in WPF 4">Neues in WPF 4</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.biggle.de/blog/weitere-neuerungen-veraenderungen-im-net-framework-4-0/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Parallele Programmierung mit .NET 4.0</title>
		<link>http://www.biggle.de/blog/parallele-programmierung-mit-net-4-0</link>
		<comments>http://www.biggle.de/blog/parallele-programmierung-mit-net-4-0#comments</comments>
		<pubDate>Fri, 12 Mar 2010 08:35:29 +0000</pubDate>
		<dc:creator>Mario Priebe</dc:creator>
				<category><![CDATA[CSharp]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[.NET4.0]]></category>
		<category><![CDATA[Basta]]></category>
		<category><![CDATA[Concurrency]]></category>
		<category><![CDATA[PLINQ]]></category>
		<category><![CDATA[Task]]></category>

		<guid isPermaLink="false">http://www.biggle.de/blog/?p=4074</guid>
		<description><![CDATA[Ich hab kürzlich die BASTA Spring 2010 besucht (über 500 Teilnehmer). Es war wirklich eine sehr informative Veranstaltung über aktuelle Entwicklungen im .NET Bereich. Folgender Abriss soll die Neuerungen im .NET Framework 4.0, Entity Framework 2, VisualStudio 2010, WPF 4 und Silverlight 4, aufzeigen. Im folgenden Artikel möchte ich über das Neue in der parallelen [...]]]></description>
			<content:encoded><![CDATA[<p>Ich hab kürzlich die BASTA Spring 2010 besucht (über 500 Teilnehmer). Es war wirklich eine sehr informative Veranstaltung über aktuelle Entwicklungen im .NET Bereich. Folgender Abriss soll die Neuerungen im .NET Framework 4.0, Entity Framework 2, VisualStudio 2010, WPF 4 und Silverlight 4, aufzeigen.</p>
<p><a href="http://www.biggle.de/blog/wp-content/uploads/2010/03/bastalogo1.jpg"><img src="http://www.biggle.de/blog/wp-content/uploads/2010/03/bastalogo1.jpg" alt="" title="bastalogo1" width="500" height="77" class="alignnone size-full wp-image-4079" /></a></p>
<p>Im folgenden Artikel möchte ich über das Neue in der parallelen Programmierung mit dem .NET 4.0 Framework  schreiben:</p>
<p>&nbsp;</p>
<h2>Parallel Programming &#8211; PLINQ, Task, Concurrency</h2>
<p>In der Vergangenheit konnten Anwendungen automatisch von neueren Prozessoren mit höheren Taktfrequenzen profitieren (Jedes Jahr Verdopplung der Taktfrequenz). Diese Gesetzmäßigkeit wird sich in der Zukunft nicht mehr fortsetzen (Wärmeentwicklung etc&#8230;). Die Leistungsfähigkeit moderner Prozessoren steigert sich heute in der Regel durch den gleichzeitigen Einsatz mehrerer CPU-Kerne. Da Anwendungsentwickler nicht mehr darauf bauen können, dass eine sequentiell implementierte Anwendung auf einer neueren CPU-Generation schneller ausgeführt wird, müssen die Möglichkeiten der Multicore-Technologie gezielt genutzt werden. Der Schlüssel dazu lautet &#8220;Parallel Computing&#8221;.</p>
<p>Man unterscheidet hier zwischen lineares Aufteilen von Aufgaben und Daten, sowie zwischen hierarchisches Aufteilen von Aufgaben und Daten.</p>
<p>&nbsp;</p>
<h2>Task</h2>
<p>Der Task Parallel Library (TPL) ist ein Satz von öffentlichen Typen und APIs im System.Threading und System.Threading.Tasks Namespaces in .NET Framework 4.0. Diese Typen verlassen sich auf einen Taskplaner, die in der .NET ThreadPool integriert ist. Die TPL hilft den Entwicklern, Produktivität zu steigern und die Parallelität in den Anwendungen vereinfacht.</p>
<p>Entwickler teilt Algorithmus auf Tasks auf.</p>
<ul type="disc">
<li>TPL teilt diese Tasks den einzelnen CPUs (Kernen) zu. </li>
<li>Auslastung vorhandener Ressourcen und Skalierbarkeit </li>
</ul>
<p>Beispiel Task erzeugen</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">using <span style="color: #990000;">System</span><span style="color: #339933;">.</span>Threading<span style="color: #339933;">.</span>Tasks<span style="color: #339933;">;</span>
void DoStuff<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> Console<span style="color: #339933;">.</span>WriteLine<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Hello!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
  Task t <span style="color: #339933;">=</span> Task<span style="color: #339933;">.</span>Factory<span style="color: #339933;">.</span>StartNew<span style="color: #009900;">&#40;</span>DoStuff<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  t<span style="color: #339933;">.</span>Wait<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Lambda Alternative</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">using <span style="color: #990000;">System</span><span style="color: #339933;">.</span>Threading<span style="color: #339933;">.</span>Tasks<span style="color: #339933;">;</span>
Task t <span style="color: #339933;">=</span> Task<span style="color: #339933;">.</span>Factory<span style="color: #339933;">.</span>StartNew<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=&gt;</span> Console<span style="color: #339933;">.</span>WriteLine<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Hello!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
t<span style="color: #339933;">.</span>Wait<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h3>Task und parallele Schleifen</h3>
<p>Beispiele:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">Parallel<span style="color: #339933;">.</span><span style="color: #b1b100;">ForEach</span><span style="color: #009900;">&#40;</span>List<span style="color: #339933;">&lt;</span>Persons<span style="color: #339933;">&gt;,</span> <span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span> <span style="color: #339933;">=&gt;</span> Console<span style="color: #339933;">.</span>WriteLine<span style="color: #009900;">&#40;</span>p<span style="color: #339933;">.</span>Name<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Parallel<span style="color: #339933;">.</span><span style="color: #b1b100;">For</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span> <span style="color: #339933;">=&gt;</span> Console<span style="color: #339933;">.</span>WriteLine<span style="color: #009900;">&#40;</span>i<span style="color: #339933;">.</span>ToString<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h3>Task mit Rückgabewerte</h3>
<p>Beispiele:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">Task t <span style="color: #339933;">=</span> <span style="color: #339933;">...</span>
Task<span style="color: #339933;">.</span>Factory<span style="color: #339933;">.</span>StartNew<span style="color: #339933;">&lt;</span>Person<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #339933;">...</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Person p <span style="color: #339933;">=</span> t<span style="color: #339933;">.</span>Result<span style="color: #339933;">;</span></pre></td></tr></table></div>

<h3>Task-Ketten</h3>
<p>Beispiele:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">Task<span style="color: #339933;">&lt;</span>Person<span style="color: #339933;">&gt;</span> task <span style="color: #339933;">=</span> Task<span style="color: #339933;">.</span>Factory<span style="color: #339933;">.</span>StartNew<span style="color: #339933;">&lt;</span>Person<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=&gt;</span> DoWithPerson<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Task task2 <span style="color: #339933;">=</span> task<span style="color: #339933;">.</span>ContinueWith<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>t<span style="color: #009900;">&#41;</span> <span style="color: #339933;">=&gt;</span> AndNowDoAnyWithPerson<span style="color: #009900;">&#40;</span>t<span style="color: #339933;">.</span>Result<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h3>Auf Task warten</h3>
<p>Beispiele:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">t<span style="color: #339933;">.</span>Wait<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Task<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> tasks <span style="color: #339933;">=</span> <span style="color: #339933;">...</span>
Task<span style="color: #339933;">.</span>WaitAll<span style="color: #009900;">&#40;</span>tasks<span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span>finishedTasks<span style="color: #009900;">&#41;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #339933;">...</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Task<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> tasks <span style="color: #339933;">=</span> <span style="color: #339933;">...</span>
Task<span style="color: #339933;">.</span>WaitAny<span style="color: #009900;">&#40;</span>tasks<span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span>finishedTasks<span style="color: #009900;">&#41;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #339933;">...</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h3>Task abbrechen</h3>
<p>Beispiele:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> source <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> CancellationTokenSource<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
CancellationToken token <span style="color: #339933;">=</span> source<span style="color: #339933;">.</span>Token<span style="color: #339933;">;</span>
Task t <span style="color: #339933;">=</span> Task<span style="color: #339933;">.</span>Factory<span style="color: #339933;">.</span>StartNew<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>token<span style="color: #339933;">.</span>IsCancellationRequested<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    throw <span style="color: #000000; font-weight: bold;">new</span> OperationCanceledException<span style="color: #009900;">&#40;</span>token<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
source<span style="color: #339933;">.</span>Cancel<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h3>Task Exceptionhandling</h3>
<p>Beispiele:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">try <span style="color: #009900;">&#123;</span>
  Task t <span style="color: #339933;">=</span> Task<span style="color: #339933;">.</span>Factory<span style="color: #339933;">.</span>StartNew<span style="color: #009900;">&#40;</span><span style="color: #339933;">...</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  source<span style="color: #339933;">.</span>Cancel<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  t<span style="color: #339933;">.</span>Wait<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
catch <span style="color: #009900;">&#40;</span>AggregateException ae<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  ae<span style="color: #339933;">.</span>Handle<span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900;">&#123;</span>
  Console<span style="color: #339933;">.</span>WriteLine<span style="color: #009900;">&#40;</span>e<span style="color: #339933;">.</span>Message<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p><br class="spacer_" /></p>
<h2>PLINQ</h2>
<p>Parallel LINQ (PLINQ) ist eine parallele Implementierung vom LINQ-Muster. PLINQ-Abfrage in vielerlei Hinsicht ähnelt eine nicht parallelen LINQ to Objects-Abfrage.PLINQ-Abfragen, wie sequenzielle LINQ Abfragen beziehen sich auf alle im Arbeitsspeicher IEnumerable oder IEnumerable<T> Daten Quelldateien und haben verzögerte Ausführung bedeutet, dass Sie nicht beginnen ausgeführt, bis die Abfrage aufgelistet wird.Der Hauptunterschied besteht darin, dass PLINQ versucht, in vollem Umfang alle Prozessoren zu auf dem System nutzen.Dies geschieht, indem Partitionierung der Datenquelle in Segmente und anschließend die Abfrage für jedes Segment auf separate Arbeitsthreads parallel auf mehreren Prozessoren ausführen.Parallele Ausführung bedeutet in vielen Fällen, dass die Abfrage erheblich schneller ausgeführt wird.</p>
<p>Beispiel:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> q <span style="color: #339933;">=</span> from p in menu<span style="color: #339933;">.</span>AsParallel<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
where p<span style="color: #339933;">.</span>Price <span style="color: #339933;">&gt;=</span> <span style="color: #cc66cc;">4</span>
select p<span style="color: #339933;">.</span>Name<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">var</span> q <span style="color: #339933;">=</span> from p in menu
  <span style="color: #339933;">.</span>AsParallel<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
  <span style="color: #339933;">.</span>AsOrdered<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
  <span style="color: #339933;">.</span>WithCancellation<span style="color: #009900;">&#40;</span>token<span style="color: #009900;">&#41;</span>
  <span style="color: #339933;">.</span>WithDegreeOfParallelism<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span>
  <span style="color: #339933;">.</span>WithExecutionMode<span style="color: #009900;">&#40;</span>…<span style="color: #009900;">&#41;</span>
  <span style="color: #339933;">.</span>WithMergeOptions<span style="color: #009900;">&#40;</span>…<span style="color: #009900;">&#41;</span>
  where p<span style="color: #339933;">.</span>Price <span style="color: #339933;">&gt;=</span> <span style="color: #cc66cc;">4</span>
  select p<span style="color: #339933;">.</span>Name<span style="color: #339933;">;</span></pre></td></tr></table></div>

<h3>Partitionierung in PLINQ</h3>
<p><a href="http://www.biggle.de/blog/wp-content/uploads/2010/03/plinqpartitionieren.png"><img class="alignnone size-full wp-image-4075" title="plinqpartitionieren" src="http://www.biggle.de/blog/wp-content/uploads/2010/03/plinqpartitionieren.png" alt="" width="500" /></a></p>
<p>Beipiel:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009900;">&#40;</span>from x in D<span style="color: #339933;">.</span>AsParallel<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> where p<span style="color: #009900;">&#40;</span>x<span style="color: #009900;">&#41;</span> select x<span style="color: #339933;">*</span>x<span style="color: #339933;">*</span>x<span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>Sum<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Quellen:</p>
<ul type="disc">
<li>Einführung in      PLINQ <a href="http://msdn.microsoft.com/de-de/library/dd997425%28VS.100%29.aspx">[1]</a> </li>
<li>Parallelität      Schnellansicht <a href="http://msdn.microsoft.com/de-de/library/dd537632%28v=VS.100%29.aspx">[2]</a> </li>
<li>Cancellation      Framework <a href="http://blogs.msdn.com/pfxteam/archive/2009/05/22/9635790.aspx">[3]</a> </li>
</ul>
<p>Webcasts:</p>
<ul type="disc">
<li>Einführung <a href="http://channel9.msdn.com/posts/Dariusz/Task-Parallel-Library-Tasks/">[4]</a> </li>
<li>Tasks verketten <a href="http://channel9.msdn.com/posts/Dariusz/Task-Parallel-Library-Task-Continuations/">[5]</a> </li>
<li>Exception      handling <a href="http://channel9.msdn.com/posts/Dariusz/Task-Parallel-Library-Exception-Handling/">[6]</a> </li>
<li>Empfehlenswerte      6teilige Serie von Bernd Marquardt (Parallelprogrammierung mit der Task      Parallel Library) <a href="http://www.microsoft.com/germany/msdn/webcasts/serien/MSDNWCS-0905-01.mspx">[7]</a> </li>
</ul>
<p>Weitere Downloads:</p>
<ul type="disc">
<li>Understanding and      Applying Parallel Patterns with the .NET Framework 4 [pdf] <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=86b3d32b-ad26-4bb8-a3ae-c1637026c3ee&amp;displaylang=en">download</a> </li>
</ul>
<p><br class="spacer_" /></p>
<h2>Concurrency</h2>
<h3>Concurrency Runtime (C++)</h3>
<p>Der Concurrency Runtime Scheduler ist ein &#8220;stehlender&#8221; Algorithmus zum Verteilen der Arbeit unter den Computerressourcen. Tasks werden auf die Worker Threads verteilt und parallel ausgeführt. Sobald einer der Worker Threads nichts zu tun hat, &#8220;stiehlt&#8221; er eine laufende Aufgabe eines anderen Worker Threads, was zu einer besseren Auslastung der vorhandenen Prozessorkerne führt.</p>
<h3>Architektur</h3>
<p>Die Concurrency Runtime ist in vier Komponenten eingeteilt</p>
<ul type="disc">
<li>Parallel Patterns Library      (PPL) </li>
<li>Asynchronous Agents Library </li>
<li>Task Scheduler </li>
<li>Resource Manager </li>
</ul>
<p>Die Komponenten befinden sich zwischen dem Betriebssystem und der Anwendung. Die folgende Abbildung zeigt, wie die Laufzeitkomponenten zwischen OS und Applikation interagieren:</p>
<p><a href="http://www.biggle.de/blog/wp-content/uploads/2010/03/concurrency.png"><img class="alignnone size-full wp-image-4076" title="concurrency" src="http://www.biggle.de/blog/wp-content/uploads/2010/03/concurrency.png" alt="" width="416" height="233" /></a></p>
<p>Quellen:</p>
<ul type="disc">
<li>Parallel Patterns      Library <a href="http://msdn.microsoft.com/en-us/library/dd492418%28v=VS.100%29.aspx">[1]</a> </li>
<li>Asynchronous      Agents Library <a href="http://msdn.microsoft.com/en-us/library/dd492627%28v=VS.100%29.aspx">[2]</a> </li>
<li>Task Scheduler <a href="http://msdn.microsoft.com/en-us/library/dd984036%28v=VS.100%29.aspx">[3]</a></li>
</ul>
<p>Im nächsten Artikel schreibe ich über weitere Neuerungen und Veränderungen im .NET Framework 4.0</p>
<p><br class="spacer_" /></p>
<p><br class="spacer_" /></p>
<hr /><p style="float:right; font-size:0.9em;">Dieser Beitrag stammt von <a href="http://www.biggle.de">Mario Priebe</a>.</p><h2  class="related_post_title">Ähnliche Beiträge</h2><ul class="related_post"><li>12. März 2010 -- <a href="http://www.biggle.de/blog/neuerungen-in-visual-studio-2010" title="Neuerungen in Visual Studio 2010">Neuerungen in Visual Studio 2010</a></li><li>12. März 2010 -- <a href="http://www.biggle.de/blog/weitere-neuerungen-veraenderungen-im-net-framework-4-0" title="Weitere Neuerungen im .NET Framework 4.0">Weitere Neuerungen im .NET Framework 4.0</a></li><li>12. März 2010 -- <a href="http://www.biggle.de/blog/named-optional-arguments-covariance-contravariance-dynamic-und-com-interop" title="Named &#038; Optional Arguments, Co- &#038; Contravariance, Dynamic und COM Interop">Named &#038; Optional Arguments, Co- &#038; Contravariance, Dynamic und COM Interop</a></li><li>25. Juli 2010 -- <a href="http://www.biggle.de/blog/dynamische-klasse-mit-dynamicobject-erstellen" title="Dynamische Klasse mit DynamicObject erstellen">Dynamische Klasse mit DynamicObject erstellen</a></li><li>12. März 2010 -- <a href="http://www.biggle.de/blog/neues-in-wpf-4" title="Neues in WPF 4">Neues in WPF 4</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.biggle.de/blog/parallele-programmierung-mit-net-4-0/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Named &amp; Optional Arguments, Co- &amp; Contravariance, Dynamic und COM Interop</title>
		<link>http://www.biggle.de/blog/named-optional-arguments-covariance-contravariance-dynamic-und-com-interop</link>
		<comments>http://www.biggle.de/blog/named-optional-arguments-covariance-contravariance-dynamic-und-com-interop#comments</comments>
		<pubDate>Fri, 12 Mar 2010 08:11:23 +0000</pubDate>
		<dc:creator>Mario Priebe</dc:creator>
				<category><![CDATA[CSharp]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[.NET4.0]]></category>
		<category><![CDATA[Basta]]></category>
		<category><![CDATA[EntityFramework2]]></category>
		<category><![CDATA[Silverlight4]]></category>
		<category><![CDATA[VS2010]]></category>
		<category><![CDATA[WPF4]]></category>

		<guid isPermaLink="false">http://www.biggle.de/blog/?p=4053</guid>
		<description><![CDATA[