<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Olivier's Blog</title>
	<atom:link href="http://odalet.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://odalet.wordpress.com</link>
	<description>Dieu a inventé le chat pour que l’homme puisse caresser le tigre</description>
	<lastBuildDate>Wed, 21 Sep 2011 07:50:12 +0000</lastBuildDate>
	<language></language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='odalet.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Olivier's Blog</title>
		<link>http://odalet.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://odalet.wordpress.com/osd.xml" title="Olivier&#039;s Blog" />
	<atom:link rel='hub' href='http://odalet.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Mes TechDays 2010</title>
		<link>http://odalet.wordpress.com/2010/02/14/mes-techdays-2010/</link>
		<comments>http://odalet.wordpress.com/2010/02/14/mes-techdays-2010/#comments</comments>
		<pubDate>Sun, 14 Feb 2010 15:59:59 +0000</pubDate>
		<dc:creator>Olivier</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[fr]]></category>

		<guid isPermaLink="false">http://odalet.wordpress.com/2010/02/14/mes-techdays-2010/</guid>
		<description><![CDATA[Cela fait maintenant presque trois ans que je n’ai pas touché à mon blog… il serait peut-être temps de s’y remettre ! Aussi vais-je parler ici des 3 jours que j’ai passés à Paris du 8 au 10 février à l’occasion des TechDays 2010. Je ne détaillerai pas l’ensemble des sessions auxquelles j’ai assisté mais [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=odalet.wordpress.com&amp;blog=19103&amp;post=76&amp;subd=odalet&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Cela fait maintenant presque trois ans que je n’ai pas touché à mon blog… il serait peut-être temps de s’y remettre !</p>
<p>Aussi vais-je parler ici des 3 jours que j’ai passés à Paris du 8 au 10 février à l’occasion des TechDays 2010. Je ne détaillerai pas l’ensemble des sessions auxquelles j’ai assisté mais me concentrerai sur les sujets qui m’ont le plus intéressé.</p>
<h2>F#</h2>
<p>J’ai assisté à 2 sessions sur F# ; la première était un atelier nous permettant de prendre en main le langage. La seconde était destinée à montrer de réelles applications de F#. Ces deux sessions étaient présentées par <strong>Don Syme</strong>, l’inventeur de F#, rien de moins (qui nous a aussi donné les génériques de C# 2…)</p>
<h3>Getting Started</h3>
<p>Pour la première session, nous avons eu droit à un tutorial sur F# qui partait réellement des bases : </p>
<pre class="code"><font size="2">printfn <span style="color:maroon;">&quot;Hello, World!&quot;</span></font></pre>
<p>Rapidement cependant, les nouveautés dans la manière de coder et de penser apparaissent. En vrac :</p>
<ul>
<li>Initialisation de listes avec n’importe quelle expression énumérable, </li>
<li>Pattern-matching : sorte de super switch/case </li>
<li>Pipe : chaînage d’appels de fonctions avec l’opérateur |&gt; : les “fluent interfaces” sont ainsi intégrées au langage. </li>
<li>Parallélisation : Async.Start, agents (MailboxProcessor) permettant la programmation parallèle par passage de messages à des agents concurrents. </li>
</ul>
<p>Bref, si vous avez aimé les extensions ajoutées à C# 3 (types anonymes, inférence, Linq, lambdas et extensions parallèles (à venir dans .NET 4) vous adorerez F#.</p>
<h3>Real life usage</h3>
<p>La seconde session s’est attachée à montrer que F# était plus qu’une curiosité de laboratoire et pouvait servir dans la vraie vie au travers de trois exemples :</p>
<p>Tout d’abord, et l’on pourra objecter que ceci intéresse surtout les scientifiques, dans le domaine de la simulation numérique :<img style="display:block;float:none;margin-left:auto;margin-right:auto;border-width:0;" title="image" border="0" alt="image" src="http://odalet.files.wordpress.com/2010/02/image_thumb.png?w=620&#038;h=442" width="620" height="442" /></p>
<p>Au delà de l’aspect graphique (le rendu est effectué par DirectX), cette démonstration montre les capacités en matière de parallélisation de F# : sur la capture ci-dessous, chaque anneau (les petits doughnuts blancs avec une flèche) est géré par un “agent” différent. Ce que la capture statique ci-dessus ne montre pas est que la surface est définie par une fonction de 3 paramètres dont le temps : elle est animée. Chaque anneau se déplace en suivant les contours de la surface !</p>
<p>Les deux autres exemples montraient d’une façon très différente comment cibler des architectures différentes lors de la compilation :</p>
<h4>Premier exemple</h4>
<p><strong>Robert Pickering</strong> nous présente le jeu de la vie. Là encore, ce n’est pas tous les jours que nos clients nous demandent d’implémenter le jeu de la vie dans leur solution… Tout l’intérêt de la démonstration était ailleurs : nous avons vu tourner l’application une première fois compilée pour x64, classique et lent, puis pour la GPU ! Les cartes graphiques modernes disposent de processeurs particuliers que l’on peut qualifier d’aptes au traitement massivement parallèle : on atteint une dimension dans le parallélisme qui n’a plus grand chose à voir avec les applications classiques que l’on optimise pour 2, 4 ou 8 cœurs. Le revers de la médaille : le code a l’air tout bonnement incompréhensible (pour le peu que j’en ai vu). Cibler ce type d’architectures implique de repenser totalement les algorithmes : les objets que les GPU aiment traiter ne sont pas de bêtes variables mais des vecteurs et des matrices (et plus leurs dimensions sont élevées, plus la puissance du processeur s’exprime).</p>
<p>J’avoue qu’à part dans des cas spécifiques : traitement de données facilement représentable de manière matricielle, informatique scientifique, traitement d’image, je ne vois pas vraiment comment appliquer ces techniques demain dans mes projets.</p>
<h4>Deuxième exemple</h4>
<p>Là, on commence à toucher au monde professionnel. <strong>Adam Granicz</strong> est le fondateur de Intellifactory et il propose un outil mignon tout plein : WebSharper. En gros il s’agit d’un GWT (ou d’un Volta) à la sauce F# : du F# que du F#. Des attributs permettent de cibler le serveur ou le client et, en fonction, du code .NET classique ou du Javascript est généré.&#160; Le layout HTML se déclare en imbriquant des listes F# : le code résultant est plutôt agréable et pas si différent de ce que de nombreux moteurs de templating MVC font. Il m’a semblé particulièrement intelligent de partir de F# pour générer du Javascript : en effet, les deux langages ont déjà beaucoup en commun (Javascript est déjà très fortement fonctionnel) et cela a du simplifier la traduction. Evidemment, les capacités parallèles de F# sont intraduisibles en Javascript (pas de multi-threading en Javascript). </p>
<p>Enfin, j’ai demandé à <strong>Adam Granicz</strong> quelle tête pouvaient bien avoir les pages générées : la page est-elle entièrement construite par du code Javascript dans le onLoad ou bien les balises HTML sont-elles émises ? Et bien oui et non : le rendu final en HTML est produit ce qui permet, entre autres, aux moteurs de recherche d’indexer correctement la page ; mais dès le chargement, le Javascript du onLoad supprime le DOM entier et le recrée… J’aurais peut-être préféré que le DOM reste à sa place et que le code Javascript remplisse les trous plutôt qu’il efface tout… Je suppose que de très bonnes raisons les ont poussé à faire ceci.</p>
<p>A noter que WebSharper intègre de nombreuses bibliothèques Javascript connues (jQuery, Yahoo UI) et les expose à F#. Le développeur peut aussi intégrer lui-même des bibliothèques Javascript (c’est une sorte d’Interop Javascript &lt;—&gt; F#…).</p>
<h3>Quelques liens</h3>
<ul>
<li>F# samples (pour Visual Studio 2008 et 2010) : <a href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=fsharpsamples&amp;DownloadId=7636"><u><font color="#0066cc">http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=fsharpsamples&amp;DownloadId=7636</font></u></a> </li>
<li>F# February 2010 CTP (fonctionne dans Visual Studio 2008 ou en ligne de commande) : <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=ba52e650-4e77-4b0b-b987-9f9ecd3bab3b&amp;displaylang=en"><u><font color="#0066cc">http://www.microsoft.com/downloads/details.aspx?FamilyID=ba52e650-4e77-4b0b-b987-9f9ecd3bab3b&amp;displaylang=en</font></u></a> </li>
<li>Le blog de <strong>Don Syme</strong> : <a href="http://blogs.msdn.com/dsyme/archive/2010/02/09/f-tutorial-and-talk-today-at-techdays-paris-late-announcement.aspx"><u><font color="#0066cc">http://blogs.msdn.com/dsyme/archive/2010/02/09/f-tutorial-and-talk-today-at-techdays-paris-late-announcement.aspx</font></u></a> </li>
<li>Le blog de <strong>Robert Pickering</strong> : <a href="http://strangelights.com/blog/"><u><font color="#0066cc">http://strangelights.com/blog/</font></u></a> </li>
<li><strong>Intellifactory</strong>, éditeur de WebSharper : <a href="http://www.intellifactory.com/"><u><font color="#0066cc">http://www.intellifactory.com/</font></u></a>&#160; </li>
</ul>
<h2>System.Identity</h2>
<p><strong>Kim Cameron</strong>, Distinguished Engineer de la division sécurité et identité de Microsoft nous propose une session à l’intitulé alléchant <strong>&#8216;M&#8217;-Based System.Identity Model for Accessing Directory Services</strong>.</p>
<p>Il part du constat qu’Active Directory n’est pas adapté aux nouveaux besoins en matière d’identité : avec sa structure trop hiérarchique, il est difficile d’y représenter des liens entre personnes (comme le font les réseaux sociaux par exemple). Un autre point important est qu’Active Directory n’est pas abandonné, ni modifié : le nouveau modèle se place au dessus d’un AD existant : il l’étend.</p>
<p>Ce qui m’a le plus intéressé dans cette présentation n’est pas tant les liens avec Active Directory (d’ailleurs pas encore implémentés à l’heure actuelle) que le méta modèle sur lequel s’appuie la nouvelle architecture. Ce modèle est défini en utilisant les outils du projet Oslo (renommé récemment en SQL Server Modeling). Le langage M fait partie de ce projet est sert à décrire des modèles de niveau conceptuel. On a donc bien ici, non seulement un méta-modèle de représentation des identités numériques, mais un modèle logique. Bien que le schéma ci-dessous fasse penser à du pseudo UML, la technologie d’implémentation n’est pas définie :</p>
<p><a href="http://odalet.files.wordpress.com/2010/02/612f60bcca2146008ec890932ec4ff62.jpg"><img style="display:block;float:none;margin-left:auto;margin-right:auto;border-width:0;" title="612f60bc-ca21-4600-8ec8-90932ec4ff62" border="0" alt="612f60bc-ca21-4600-8ec8-90932ec4ff62" src="http://odalet.files.wordpress.com/2010/02/612f60bcca2146008ec890932ec4ff62_thumb.jpg?w=704&#038;h=435" width="704" height="435" /></a> </p>
<p>Dans la pratique, et dans sa version actuelle, le modèle est effectivement implémenté au dessus de SQL Server. Cependant, comme le montre ce deuxième schéma, plusieurs “providers” sont prévus, dont évidemment Active Directoy. La partie de gauche du schéma montre l’état actuel classique d’interrogation d’un annuaire Active Directory. La partie de droite, quant à elle représente le futur. L’API System.Identity permet une unification des accès aux sources de données quel que soit le type de magasin sous-jacent :</p>
<p><a href="http://odalet.files.wordpress.com/2010/02/d34262e9419349238a2ee4276a5625f7.jpg"><img style="display:block;float:none;margin-left:auto;margin-right:auto;border-width:0;" title="d34262e9-4193-4923-8a2e-e4276a5625f7" border="0" alt="d34262e9-4193-4923-8a2e-e4276a5625f7" src="http://odalet.files.wordpress.com/2010/02/d34262e9419349238a2ee4276a5625f7_thumb.jpg?w=698&#038;h=458" width="698" height="458" /></a> </p>
<p>Dans sa présentation, <strong>Kim Cameron</strong> a donné quelques exemples d’utilisation de l’API. Le code est clair est simple, le support Intellisense complet. Cette dernière remarque semble banale et pourtant : une des forces du modèle est qu’il est extensible (soit par simple paramétrage XML pour les “Kinds” par exemple, soit en modifiant directement le modèle logique avec les outils Oslo). Un modèle modifié ou étendu est ensuite passé dans une moulinette qui génère un assembly wrapper. On dispose ainsi d’aides au codage, même sur ses propres extensions.</p>
<p>En bref, une présentation très intéressante. Je n’ai été déçu que sur un seul point. Bien que le titre de la présentation cite M, nous n’avons pas vu une seule ligne de code et les outils d’Oslo (Quadrant, ipad…) n’ont même pas été cités. </p>
<h3>Quelques liens</h3>
<p>Le blog de <strong>Kim Cameron</strong> : <a href="http://www.identityblog.com/"><u><font color="#0066cc">http://www.identityblog.com/</font></u></a></p>
<p><span style="widows:2;text-transform:none;text-indent:0;border-collapse:separate;font:small arial, sans-serif;white-space:normal;orphans:2;letter-spacing:normal;color:rgb(0,0,0);word-spacing:0;" class="Apple-style-span"></span></p>
<h2>Autres sessions, en vrac</h2>
<ul>
<li>
<h2><span style="widows:2;text-transform:none;text-indent:0;border-collapse:separate;font:small arial, sans-serif;white-space:normal;orphans:2;letter-spacing:normal;color:rgb(0,0,0);word-spacing:0;" class="Apple-style-span"><strong>Le futur de XAML dans le framework .NET et Silverlight</strong> présenté par <strong>Mitsu Furuta</strong> de Microsoft France : <span style="widows:2;text-transform:none;text-indent:0;border-collapse:separate;font:small arial, sans-serif;white-space:normal;orphans:2;letter-spacing:normal;color:rgb(0,0,0);word-spacing:0;" class="Apple-style-span">System.Xaml est un nouvel assembly factorisant la sérialisation/désérialisation XAML pour toutes les technologies qui l’utilisent (WPF, Silverlight, WF…). <strong>Mitsu Furuta</strong> nous montre comment tirer partie de ces nouvelles classes pour sérialiser nos propres graphes d’objet.</span></span></h2>
</li>
<li>
<h2><span style="widows:2;text-transform:none;text-indent:0;border-collapse:separate;font:small arial, sans-serif;white-space:normal;orphans:2;letter-spacing:normal;color:rgb(0,0,0);word-spacing:0;" class="Apple-style-span"><span style="widows:2;text-transform:none;text-indent:0;border-collapse:separate;font:small arial, sans-serif;white-space:normal;orphans:2;letter-spacing:normal;color:rgb(0,0,0);word-spacing:0;" class="Apple-style-span">Deux sessions présentées par SOGETI : <strong>Visual Studio : comment l&#8217;adapter à vos besoins</strong> et <strong>Comment optimiser la qualité de son code par la mise en place de bonnes</strong> <strong>pratiques</strong> :</span></span></h2>
</li>
</ul>
<ul>
<li>
<h2><span style="widows:2;text-transform:none;text-indent:0;border-collapse:separate;font:small arial, sans-serif;white-space:normal;orphans:2;letter-spacing:normal;color:rgb(0,0,0);word-spacing:0;" class="Apple-style-span"><span style="widows:2;text-transform:none;text-indent:0;border-collapse:separate;font:small arial, sans-serif;white-space:normal;orphans:2;letter-spacing:normal;color:rgb(0,0,0);word-spacing:0;" class="Apple-style-span"></span></span><span style="widows:2;text-transform:none;text-indent:0;border-collapse:separate;font:small arial, sans-serif;white-space:normal;orphans:2;letter-spacing:normal;color:rgb(0,0,0);word-spacing:0;" class="Apple-style-span"><span style="widows:2;text-transform:none;text-indent:0;border-collapse:separate;font:small arial, sans-serif;white-space:normal;orphans:2;letter-spacing:normal;color:rgb(0,0,0);word-spacing:0;" class="Apple-style-span">La première session présente le nouveau modèle d’extensibilité de Visual Studio 2010 : déploiement simplifié et plus rapide (fichiers <strong>vsix</strong>) et plugins basés sur MEF.</span></span></h2>
</li>
<li>
<h2><span style="widows:2;text-transform:none;text-indent:0;border-collapse:separate;font:small arial, sans-serif;white-space:normal;orphans:2;letter-spacing:normal;color:rgb(0,0,0);word-spacing:0;" class="Apple-style-span"><span style="widows:2;text-transform:none;text-indent:0;border-collapse:separate;font:small arial, sans-serif;white-space:normal;orphans:2;letter-spacing:normal;color:rgb(0,0,0);word-spacing:0;" class="Apple-style-span"></span></span><span style="widows:2;text-transform:none;text-indent:0;border-collapse:separate;font:small arial, sans-serif;white-space:normal;orphans:2;letter-spacing:normal;color:rgb(0,0,0);word-spacing:0;" class="Apple-style-span"><span style="widows:2;text-transform:none;text-indent:0;border-collapse:separate;font:small arial, sans-serif;white-space:normal;orphans:2;letter-spacing:normal;color:rgb(0,0,0);word-spacing:0;" class="Apple-style-span">La seconde, après avoir rappelé quelques bonnes pratiques généralement acceptées, présente le framework Code Contracts qui propose des outils d’analyse à la compilation et au runtime garantissant un code robuste (pré et post conditions, invariants). A noter que Jonathan “Peli” de Halleux était dans la salle.</span></span></h2>
</li>
</ul>
<li>
<h2><span style="widows:2;text-transform:none;text-indent:0;border-collapse:separate;font:small arial, sans-serif;white-space:normal;orphans:2;letter-spacing:normal;color:rgb(0,0,0);word-spacing:0;" class="Apple-style-span"><span style="widows:2;text-transform:none;text-indent:0;border-collapse:separate;font:small arial, sans-serif;white-space:normal;orphans:2;letter-spacing:normal;color:rgb(0,0,0);word-spacing:0;" class="Apple-style-span">Les nouveautés de Workflow Foundations 4</span></span></h2>
</li>
<li>
<h2><span style="widows:2;text-transform:none;text-indent:0;border-collapse:separate;font:small arial, sans-serif;white-space:normal;orphans:2;letter-spacing:normal;color:rgb(0,0,0);word-spacing:0;" class="Apple-style-span"><span style="widows:2;text-transform:none;text-indent:0;border-collapse:separate;font:small arial, sans-serif;white-space:normal;orphans:2;letter-spacing:normal;color:rgb(0,0,0);word-spacing:0;" class="Apple-style-span">Fuites mémoires en .NET : Détecter et corriger.</span></span></h2>
</li>
<li>
<h2><span style="widows:2;text-transform:none;text-indent:0;border-collapse:separate;font:small arial, sans-serif;white-space:normal;orphans:2;letter-spacing:normal;color:rgb(0,0,0);word-spacing:0;" class="Apple-style-span"><span style="widows:2;text-transform:none;text-indent:0;border-collapse:separate;font:small arial, sans-serif;white-space:normal;orphans:2;letter-spacing:normal;color:rgb(0,0,0);word-spacing:0;" class="Apple-style-span">Développement embarqué : Windows Embedded 6</span></span></h2>
</li>
<li>
<h2><span style="widows:2;text-transform:none;text-indent:0;border-collapse:separate;font:small arial, sans-serif;white-space:normal;orphans:2;letter-spacing:normal;color:rgb(0,0,0);word-spacing:0;" class="Apple-style-span"><span style="widows:2;text-transform:none;text-indent:0;border-collapse:separate;font:small arial, sans-serif;white-space:normal;orphans:2;letter-spacing:normal;color:rgb(0,0,0);word-spacing:0;" class="Apple-style-span">…</span></span></h2>
</li>
<h3>Liens</h3>
<ul>
<li><span style="widows:2;text-transform:none;text-indent:0;border-collapse:separate;font:small arial, sans-serif;white-space:normal;orphans:2;letter-spacing:normal;color:rgb(0,0,0);word-spacing:0;" class="Apple-style-span">Le blog de<strong> Mitsu Furuta</strong> : <a href="http://blogs.msdn.com/mitsu/"><u><font color="#0066cc">http://blogs.msdn.com/mitsu/</font></u></a></span></li>
<li><span style="widows:2;text-transform:none;text-indent:0;border-collapse:separate;font:small arial, sans-serif;white-space:normal;orphans:2;letter-spacing:normal;color:rgb(0,0,0);word-spacing:0;" class="Apple-style-span"></span><span style="widows:2;text-transform:none;text-indent:0;border-collapse:separate;font:small arial, sans-serif;white-space:normal;orphans:2;letter-spacing:normal;color:rgb(0,0,0);word-spacing:0;" class="Apple-style-span">Le blog de <strong>Peli</strong> : <a href="http://blog.dotnetwiki.org/"><u><font color="#0066cc">http://blog.dotnetwiki.org/</font></u></a> et sa page sur Microsoft Research : <a href="http://research.microsoft.com/en-us/people/jhalleux/"><u><font color="#0066cc">http://research.microsoft.com/en-us/people/jhalleux/</font></u></a></span></li>
</ul>
<h2><span style="widows:2;text-transform:none;text-indent:0;border-collapse:separate;font:small arial, sans-serif;white-space:normal;orphans:2;letter-spacing:normal;color:rgb(0,0,0);word-spacing:0;" class="Apple-style-span"></span></h2>
<p><span style="widows:2;text-transform:none;text-indent:0;border-collapse:separate;font:small arial, sans-serif;white-space:normal;orphans:2;letter-spacing:normal;color:rgb(0,0,0);word-spacing:0;" class="Apple-style-span">&#160;</span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/odalet.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/odalet.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/odalet.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/odalet.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/odalet.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/odalet.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/odalet.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/odalet.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/odalet.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/odalet.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/odalet.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/odalet.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/odalet.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/odalet.wordpress.com/76/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=odalet.wordpress.com&amp;blog=19103&amp;post=76&amp;subd=odalet&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://odalet.wordpress.com/2010/02/14/mes-techdays-2010/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/84b83058bc6f6bf7a2d9a998c3a63854?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">odalet</media:title>
		</media:content>

		<media:content url="http://odalet.files.wordpress.com/2010/02/image_thumb.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://odalet.files.wordpress.com/2010/02/612f60bcca2146008ec890932ec4ff62_thumb.jpg" medium="image">
			<media:title type="html">612f60bc-ca21-4600-8ec8-90932ec4ff62</media:title>
		</media:content>

		<media:content url="http://odalet.files.wordpress.com/2010/02/d34262e9419349238a2ee4276a5625f7_thumb.jpg" medium="image">
			<media:title type="html">d34262e9-4193-4923-8a2e-e4276a5625f7</media:title>
		</media:content>
	</item>
		<item>
		<title>The &quot;using&quot; pattern</title>
		<link>http://odalet.wordpress.com/2007/03/12/the-using-pattern/</link>
		<comments>http://odalet.wordpress.com/2007/03/12/the-using-pattern/#comments</comments>
		<pubDate>Sun, 11 Mar 2007 23:25:55 +0000</pubDate>
		<dc:creator>Olivier</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[en]]></category>

		<guid isPermaLink="false">http://odalet.wordpress.com/2007/03/12/the-using-pattern/</guid>
		<description><![CDATA[In the previous post, I&#8217;ve discussed how I misused the IDisposable.Dispose() method. Here, I will present some of the ways I use the using keyword in manners that may don&#8217;t come to mind at first (I may in a few years come back to this and realize I was totally wrong, but for now, it [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=odalet.wordpress.com&amp;blog=19103&amp;post=38&amp;subd=odalet&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In the <a href="http://odalet.wordpress.com/2007/03/08/mea-culpa-the-isdisposed-anti-pattern/">previous post</a>, I&#8217;ve discussed how I misused the <strong>IDisposable.Dispose() </strong>method. Here, I will present some of the ways I use the <strong>using</strong> keyword in manners that may don&#8217;t come to mind at first (I may in a few years come back to this and realize I was totally wrong, but for now, it seems to me the samples provided here may prove usefull).</p>
<p>According to <a href="http://msdn2.microsoft.com/en-us/library/yh598w02(VS.80).aspx">msdn</a>, the <strong>using</strong> statement &#8220;<em>Defines a scope, outside of which an object or objects will be disposed</em>&#8220;. In the remarks section of the documentation, it is also stated that &#8220;<em>The <strong>using</strong> statement allows the programmer to specify when objects that use resources should release them</em>&#8220;. And the next sentence: &#8220;<em>The object provided to the <strong>using</strong> statement must implement the <strong>IDisposable</strong> interface. This interface provides the <strong>Dispose</strong> method, which should release the object&#8217;s resources</em>&#8220;. Everything&#8217;s ok about all this, expect one little thing: by insisting on resources, it drives people to use the <strong>using</strong> keyword only with objects holding resources, or locks, or connections or whatever needs to be released to the system&#8230; </p>
<p>I think this statement can be used in an extensible manner for any object that:</p>
<ul>
<li>lives in a finite scope  </li>
<li>needs an action to be done when created and another one when you don&#8217;t need it any more.</li>
</ul>
<p>For instance, when it&#8217;s dark, and I want to write something, I need some light. So I turn it on, write my post, and turn it off before going to bed. This could be writtent this way in C#:</p>
<p><font face="Courier New">SwitchOnLight();<br />WriteThisPost();<br />SubmitIt();&nbsp;&nbsp;&nbsp;<br />SwitchOffLight();<br />GotoBed();</font></p>
<p>There are times when I&#8217;m quite tired, and I may forget to switch off the light before going to bed. This results in this code:</p>
<p><font face="Courier New">SwitchOnLight();<br />WriteThisPost();<br />SubmitIt();&nbsp;&nbsp;&nbsp;<br />GotoBed();</font></p>
<p>Here, C# programmers will have recognized that some kind of <strong>Dispose()</strong> call is missing. Enters the <strong>using </strong>keyword which allows me to write:</p>
<p><font face="Courier New">using(Light) <br />{&nbsp;</font><font face="Courier New"><br />&nbsp;&nbsp;&nbsp; WriteThisPost();<br />&nbsp;&nbsp;&nbsp; SubmitIt();&nbsp;&nbsp;&nbsp;&nbsp;<br />}<br />GoToBed();</font></p>
<p>And thus, I never forget to turn off the light before going to bed. </p>
<p>I really like the metaphor the <strong>using</strong>&nbsp;keyword provides, and I&#8217;d like to be able to use it even for objects that don&#8217;t hold any system resource. As the samples below demonstrate it, there&#8217;s nothing preventing me from doing so. The main idea is that any object that needs to do something when created, and something else when released is a good candidate for the <strong>using</strong> keyword: these two tasks are implemented in the constructor and in the <strong>IDisposable.Dispose()</strong> method. The task executed in the <strong>Dispose()</strong> method hasn&#8217;t to release resources. In fact, most of the times, It just restores a saved state.</p>
<p><u>Example 1:</u></p>
<p>In most of my windows forms applications, I&nbsp;use a base form class providing some goodies to inheritors (one of them is a wonderfull linear gradient I apply on the background of my forms &#8211; question of taste). Among these services is <strong>WaitCursor</strong>. Usually when you want to show an hourglass cursor while processing a lengthy task, you have to follow three steps:</p>
<ol>
<li>Change the cusor: <strong>this.Cursor = Cursors.WaitCursor;</strong>  </li>
<li>Execute the lengthy task in a <strong>try</strong> block  </li>
<li>Restore the normal cursor in a finally clause: <strong>finally { this.Cursor = Cursors.Default; }</strong></li>
</ol>
<p>I&#8217;ve built up a little helper class (completed with a property) which allows you to write this code, (which seems more readable to me : it&#8217;s almost well formed English):</p>
<p><font face="Courier New">using(WaitCursor) { /* execute lengthy task */ }</font></p>
<p>First, in the base form class, <strong>WaitCursor</strong>&nbsp;is a property returning an <strong>IDisposable</strong>:</p>
<p><font face="Courier New">protected IDisposable WaitCursor <br />{ <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get { return new CursorProvider(this, Cursors.Wait); } <br />}</font></p>
<p>And <strong>CursorProvider</strong> is a private inner class also defined in the base form class:</p>
<p><font face="Courier New">private class CursorProvider : IDisposable<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Control owner = null;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Cursor savedCursor = Cursors.Default;</font></p>
<p><font face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public CursorProvider(Control control, Cursor newCursor)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (control == null) <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw new ArgumentNullException(&#8220;control&#8221;);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (newCursor == null)&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;throw new ArgumentNullException(&#8220;newCursor&#8221;);</font></p>
<p><font face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; owner = control;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; savedCursor = control.Cursor;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; control.Cursor = newCursor;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; control.Refresh();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p>
<p><font face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #region IDisposable Members</font></p>
<p><font face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public void Dispose() { owner.Cursor = savedCursor; }</font></p>
<p><font face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #endregion</font><font face="Courier New"><br />}</font></p>
<p>A few explanations:</p>
<ul>
<li>The property is returning an <strong>IDisposable</strong> instance: indeed, callers don&#8217;t have to know anything else (it is intendeed to be part of a <strong>using</strong> statement) so, why would I expose more?  </li>
<li>Each time the property is called, a new object is created: you can overlap as many <strong>using</strong> statements as you wish,&nbsp;after the last closing bracket, the correct cursor will be restored.  </li>
<li>We never need the object created by the call to the property, thus the <strong>using(WaitCursor)</strong> and not some <strong>using(IDisposable foo = WaitCursor)</strong>.  </li>
<li>The class is straightforward: the constructor, after checking for null parameters, saves the current state (the current control&#8217;s cursor) then sets the new state. Inside&nbsp;<strong>Dispose()</strong> (which will always be called at the end of the <strong>using</strong> block, wether an exception has been thrown or not), the state is restored.</li>
</ul>
<p><u>Example 2:</u> <a href="http://odalet.wordpress.com/2006/08/23/saving-the-state-of-a-graphics-object/">Saving the state of a Graphics object</a>. In this old post, I exposed a way of using the <strong>GraphicsContainer</strong> class. And I wrapped it in an <strong>IDisposable</strong> object (one time again, the idea is to save a state in the constructor, and to restore it in <strong>Dispose()</strong>).</p>
<p><u>Example 3:</u> <a href="http://msdn.microsoft.com/msdnmag/issues/06/09/NETMatters">.NET Matters: Scope and more</a>. In this article from MSDN Magazine, Stephen Toub explains how to code a <strong>Scope&lt;T&gt;</strong> class to provide transactionnal behavior. This is an advanced example of&nbsp;a class&nbsp;that fits perfectly well with the <strong>using </strong>syntax. Besides the link with this post regarding the <strong>using</strong> statement, this article also discusses many other interesting .NET concepts (and in particular, the notion of thread static members). The second short article about the <strong>Semaphore</strong> class is again an example of a pretty use of the <strong>using</strong> statement.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/odalet.wordpress.com/38/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/odalet.wordpress.com/38/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/odalet.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/odalet.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/odalet.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/odalet.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/odalet.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/odalet.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/odalet.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/odalet.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/odalet.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/odalet.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/odalet.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/odalet.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/odalet.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/odalet.wordpress.com/38/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=odalet.wordpress.com&amp;blog=19103&amp;post=38&amp;subd=odalet&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://odalet.wordpress.com/2007/03/12/the-using-pattern/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/84b83058bc6f6bf7a2d9a998c3a63854?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">odalet</media:title>
		</media:content>
	</item>
		<item>
		<title>Mea culpa: the IsDisposed anti-pattern</title>
		<link>http://odalet.wordpress.com/2007/03/08/mea-culpa-the-isdisposed-anti-pattern/</link>
		<comments>http://odalet.wordpress.com/2007/03/08/mea-culpa-the-isdisposed-anti-pattern/#comments</comments>
		<pubDate>Thu, 08 Mar 2007 20:32:52 +0000</pubDate>
		<dc:creator>Olivier</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[en]]></category>

		<guid isPermaLink="false">http://odalet.wordpress.com/2007/03/08/mea-culpa-the-isdisposed-anti-pattern/</guid>
		<description><![CDATA[Back a few years ago, when I was still a new-born at C# and .NET programming, I had found myself very proud for having improved the .NET framework itself. Indeed, I had just invented the IDisposableEx interface: public interface IDisposableEx : IDisposable{&#160;&#160;&#160;&#160; bool IsDisposed { get; }} What did I use this interface for? It [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=odalet.wordpress.com&amp;blog=19103&amp;post=37&amp;subd=odalet&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Back a few years ago, when I was still a new-born at C# and .NET programming, I had found myself very proud for having improved the .NET framework itself. Indeed, I had just invented the <strong>IDisposableEx</strong> interface:</p>
<p><font face="Courier New">public interface IDisposableEx : IDisposable<br /></font><font face="Courier New">{<br /></font><font face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp; bool IsDisposed { get; }<br /></font><font face="Courier New">}</font></p>
<p>What did I use this interface for? It seemed to me a great improvement to be able to know whether or not an object had been disposed. And I was writing code like this:</p>
<p><font face="Courier New">if (!myObject.IsDisposed) myObject.Dispose();</font></p>
<p>Here lie two style errors: </p>
<ol>
<li>Not so a serious one: why calling <strong>Dispose()</strong> when a <strong>using</strong> construct would make it perfectly useless (As of now, I only call <strong>Dispose()</strong> when the object is not instanciated in the method that will dispose it)?  </li>
<li>The real big one: what is the use of the&nbsp;test on the disposed state of the object? Microsoft clearly states that a <strong>Dispose()</strong> method call should <strong>NEVER EVER</strong> fail (see <a href="http://msdn2.microsoft.com/en-us/library/system.idisposable.dispose.aspx">msdn</a>). One could call <strong>Dispose()</strong> thousands of times, there should never happen any exception. So, the test is useless.</li>
</ol>
<p>On the other hand, one could argue that testing the disposed state of the object isn&#8217;t that serious&#8230; and I agree with this; in fact, what is really misconcepted in the <strong>IDisposableEx</strong> interface is not how you use it, but what it supposes can happen inside the implementor: by allowing to test the disposed state, this interface suggests that the behavior of the<strong> Dispose()</strong> method depends on the state of the object. And even worse: if you call <strong>Dispose()</strong> and the<strong> IsDisposed</strong> property was true, then <strong>Dispose()</strong> might fail! And in some of my implementations, it did! In my mind providing a means of testing was good enough, and if your app ended with an uncaught exception, it was the developper&#8217;s fault: <em>why didn&#8217;t you test <strong>IsDisposed</strong>?</em>&#8230; my apologies go to&nbsp;them&#8230;&nbsp;</p>
<p>The correct way to handle&nbsp;multiple calls to <strong>Dispose()</strong>&nbsp;is actually to store a disposed state, but it must be inner to the object and calling code must never rely on it (so I&#8217;d &nbsp;better make this private, and remove the <strong>IDisposableEx</strong> interface &#8211; from source control if I can, so that no one ever discovers my crime):</p>
<p><font face="Courier New">private bool disposed = false;<br />&#8230;<br />public void Dispose()<br />{<br />&nbsp;&nbsp;&nbsp; if (disposed) return;<br /></font><font face="Courier New"><br />&nbsp;&nbsp;&nbsp; // disposing of allocated resources<br />&nbsp;&nbsp;&nbsp; &#8230;<br />&nbsp;&nbsp;&nbsp; // now, don&#8217;t forget to set the disposed state</font><font face="Courier New"><br />&nbsp;&nbsp;&nbsp; disposed = true; <br />}</font></p>
<p>I hope that having revealed a part of my dark past will help you not to&nbsp;make that&nbsp;mistake, or at least will it have made you laugh a bit.</p>
<p>&nbsp;</p>
<p><u>PS:</u> I can&#8217;t think of a scenario right now where a caller should be aware of the disposed state of the callee, but in such a case, the <strong>IsDisposed</strong> property seems acceptable (if you don&#8217;t want to catch numbers of <a href="http://msdn2.microsoft.com/en-us/library/system.objectdisposedexception.aspx"><strong>ObjectDisposedException</strong></a>). But I think&nbsp;this would be a really bad idea to provide this property as part of an interface&#8230; Or at least should this interface be named something like <strong>IDisposedStateNotifier</strong> so that developpers don&#8217;t think it modifies the <strong>IDisposable.Dispose</strong> standard&nbsp;behavior&#8230;</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/odalet.wordpress.com/37/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/odalet.wordpress.com/37/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/odalet.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/odalet.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/odalet.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/odalet.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/odalet.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/odalet.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/odalet.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/odalet.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/odalet.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/odalet.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/odalet.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/odalet.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/odalet.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/odalet.wordpress.com/37/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=odalet.wordpress.com&amp;blog=19103&amp;post=37&amp;subd=odalet&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://odalet.wordpress.com/2007/03/08/mea-culpa-the-isdisposed-anti-pattern/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/84b83058bc6f6bf7a2d9a998c3a63854?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">odalet</media:title>
		</media:content>
	</item>
		<item>
		<title>Log4Net: IP parsing bug when used with framework .NET 2.0</title>
		<link>http://odalet.wordpress.com/2007/01/13/log4net-ip-parsing-bug-when-used-with-framework-net-20/</link>
		<comments>http://odalet.wordpress.com/2007/01/13/log4net-ip-parsing-bug-when-used-with-framework-net-20/#comments</comments>
		<pubDate>Sat, 13 Jan 2007 00:20:29 +0000</pubDate>
		<dc:creator>Olivier</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[en]]></category>

		<guid isPermaLink="false">http://odalet.wordpress.com/2007/01/13/log4net-ip-parsing-bug-when-used-with-framework-net-20/</guid>
		<description><![CDATA[Update (2008/08/21): As stated by SergeS in his comment, the solution I provide below (while working)  should not be used any more. Instead, replace your src/Appender/UdpAppender.cs file with the one found here: https://svn.apache.org/viewvc/logging/log4net/trunk/src/Appender/UdpAppender.cs?revision=506603 I&#8217;m using log4net 1.2.10 for a few month now and couldn&#8217;t ever get rid of it. Today I was playing with the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=odalet.wordpress.com&amp;blog=19103&amp;post=35&amp;subd=odalet&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><span style="font-family:Trebuchet MS;font-size:x-small;"> </span></p>
<p><span style="color:#ff0000;"><strong>Update (2008/08/21):</strong></span></p>
<p>As stated by SergeS in his comment, the solution I provide below (while working)  should not be used any more. Instead, replace your src/Appender/UdpAppender.cs file with the one found here:</p>
<p><a href="https://svn.apache.org/viewvc/logging/log4net/trunk/src/Appender/UdpAppender.cs?revision=506603">https://svn.apache.org/viewvc/logging/log4net/trunk/src/Appender/UdpAppender.cs?revision=506603</a></p>
<p><span style="font-family:Trebuchet MS;font-size:x-small;">I&#8217;m using <a href="http://logging.apache.org/log4net/">log4net 1.2.10</a> for a few month now and couldn&#8217;t ever get rid of it. Today I was playing with the <a href="http://logging.apache.org/log4net/release/config-examples.html#udpappender">udp appender</a>: I was trying to have my application send logs via udp to <a href="http://www.devintelligence.com/log4netviewer/">Log4NetViewer</a>&#8230; and nothing happened. After having enabled the log4net debug mode <a href="#rem1">(1)</a>, I could see there was something wrong with the way log4net parsed my IP <a href="#rem2">(2)</a>: </span></p>
<p><code>log4nelog4net:ERROR [UdpAppender] Unable to send logging event to remote host ::1 on port 1234.<br />
System.Net.Sockets.SocketException: Une adresse incompatible avec le protocole demandé a été utilisée<br />
à System.Net.Sockets.Socket.SendTo(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, EndPoint remoteEP)<br />
à System.Net.Sockets.UdpClient.Send(Byte[] dgram, Int32 bytes, IPEndPoint endPoint)<br />
à log4net.Appender.UdpAppender.Append(LoggingEvent loggingEvent)</code></p>
<p><span style="font-family:Trebuchet MS;font-size:x-small;">log4net was transforming my &#8220;192.168.0.2&#8243; parameter IP into ::1, and the problem took place in the method IPAddressConverter.ConvertFrom() (the file is located under </span><span style="font-family:Courier New;">log4net-1.2.10\src\Util\TypeConverters\IPAddressConverter.cs</span>).<br />
<span style="font-family:Trebuchet MS;font-size:x-small;">The problem is that when compiled with .NET 2.0, the original code is returning the first IP address associated with the host (host itself returned by a dns lookup):</span></p>
<pre><span style="color:#008080;font-size:x-small;">IPHostEntry</span><span style="font-size:x-small;"> host = </span><span style="color:#008080;font-size:x-small;">Dns</span><span style="font-size:x-small;">.GetHostEntry(str);</span><span style="color:#0000ff;font-size:x-small;">
if</span><span style="font-size:x-small;"> (host != </span><span style="color:#0000ff;font-size:x-small;">null</span><span style="font-size:x-small;"> &amp;&amp;
    host.AddressList != </span><span style="color:#0000ff;font-size:x-small;">null</span><span style="font-size:x-small;"> &amp;&amp;
    host.AddressList.Length &gt; 0 &amp;&amp;
    host.AddressList[0] != </span><span style="color:#0000ff;font-size:x-small;">null</span><span style="font-size:x-small;">)
{ </span>
    <span style="color:#0000ff;font-size:x-small;">return</span><span style="font-size:x-small;"> host.AddressList[0];
}</span></pre>
<p><span style="font-family:Trebuchet MS;">When inspecting the content of this address list with the debugger I got:</span></p>
<p><span style="font-family:Courier New;font-size:x-small;">+        [0]    {::1}    System.Net.IPAddress<br />
+        [1]    {192.168.0.2}    System.Net.IPAddress<br />
+        [2]    {192.168.206.1}    System.Net.IPAddress<br />
+        [3]    {192.168.114.1}    System.Net.IPAddress</span><span style="font-family:Courier New;"><br />
</span></p>
<p><span style="font-family:Trebuchet MS;font-size:x-small;">So, with the existing code, the address ::1 is selected&#8230; and the UdpAppender throws an exception <img src='http://s0.wp.com/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' />  To avoid this:<br />
first I added this property to IPAddressConverter:</span></p>
<p><span style="color:#0000ff;font-size:x-small;">public</span><span style="font-size:x-small;"> </span><span style="color:#0000ff;font-size:x-small;">bool</span><span style="font-size:x-small;"> IsIPv6Supported { </span><span style="color:#0000ff;font-size:x-small;">get</span><span style="font-size:x-small;"> { </span><span style="color:#0000ff;font-size:x-small;">return</span><span style="font-size:x-small;"> </span><span style="color:#0000ff;font-size:x-small;">false</span><span style="font-size:x-small;">; } }</span></p>
<p><span style="font-family:Trebuchet MS;font-size:x-small;">note that I&#8217;m not networking aware, and thus this may be replaced by some code able to detect wether or not IP v6 is supported&#8230;<br />
then I replaced &#8220;</span><span style="color:#0000ff;font-size:x-small;">return</span><span style="font-size:x-small;"> host.AddressList[0];</span>&#8221; with:</p>
<pre><span style="color:#0000ff;font-size:x-small;">foreach</span><span style="font-size:x-small;"> (</span><span style="color:#008080;font-size:x-small;">IPAddress</span><span style="font-size:x-small;"> address </span><span style="color:#0000ff;font-size:x-small;">in</span><span style="font-size:x-small;"> host.AddressList)
{
    </span><span style="color:#0000ff;font-size:x-small;">if</span><span style="font-size:x-small;"> ((address.AddressFamily ==
        System.Net.Sockets.</span><span style="color:#008080;font-size:x-small;">AddressFamily</span><span style="font-size:x-small;">.InterNetworkV6) &amp;&amp;
        !IsIPv6Supported) </span><span style="color:#0000ff;font-size:x-small;">
        continue</span><span style="font-size:x-small;">;
                                </span>
<span style="color:#0000ff;font-size:x-small;">    return</span><span style="font-size:x-small;"> address;
</span><span style="font-size:x-small;">}</span></pre>
<pre><span style="font-family:Trebuchet MS;font-size:x-small;">This way, I return the first IPv4 address instead of the first address.Hope this helps </span></pre>
<p><span style="font-family:Trebuchet MS;color:#000000;font-size:x-small;"><a id="rem1"><span style="color:#000000;">(1) to do so, just add the following xml to your app.config:</span> </a></span></p>
<p><span style="color:#0000ff;font-size:x-small;">&lt;</span><span style="color:#800000;font-size:x-small;">appSettings</span><span style="color:#0000ff;font-size:x-small;">&gt;<br />
</span><span style="color:#0000ff;font-size:x-small;">&lt;</span><span style="color:#800000;font-size:x-small;">add</span><span style="color:#0000ff;font-size:x-small;"> </span><span style="color:#ff0000;font-size:x-small;">key</span><span style="color:#0000ff;font-size:x-small;">=</span><span style="font-size:x-small;">&#8220;</span><span style="color:#0000ff;font-size:x-small;">log4net.Internal.Debug</span><span style="font-size:x-small;">&#8220;</span><span style="color:#0000ff;font-size:x-small;"> </span><span style="color:#ff0000;font-size:x-small;">value</span><span style="color:#0000ff;font-size:x-small;">=</span><span style="font-size:x-small;">&#8220;</span><span style="color:#0000ff;font-size:x-small;">true</span><span style="font-size:x-small;">&#8220;</span><span style="color:#0000ff;font-size:x-small;">/&gt;<br />
&lt;/</span><span style="color:#800000;font-size:x-small;">appSettings</span><span style="color:#0000ff;font-size:x-small;">&gt;</span></p>
<p><span style="font-family:Courier New;font-size:x-small;"> </span></p>
<p><span style="font-family:Courier New;font-size:x-small;"> </span></p>
<p><span style="font-family:Courier New;font-size:x-small;"> </span></p>
<p><span style="font-family:Courier New;font-size:x-small;"> </span></p>
<p><span style="font-family:Trebuchet MS;color:#000000;font-size:x-small;">(2) aproximatively translated from French into English: The used address is incompatible with the requested protocol</span><span style="font-family:Trebuchet MS;color:#000000;font-size:x-small;"> </span></p>
<p><span style="font-family:Trebuchet MS;color:#000000;font-size:x-small;">PS: if you want to compile the log4net visual studio project provided with the distribution, you have to apply these guidelines: <a href="http://logging.apache.org/log4net/release/building.html#vsnet-2005">http://logging.apache.org/log4net/release/building.html#vsnet-2005</a></span></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/odalet.wordpress.com/35/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/odalet.wordpress.com/35/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/odalet.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/odalet.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/odalet.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/odalet.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/odalet.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/odalet.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/odalet.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/odalet.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/odalet.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/odalet.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/odalet.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/odalet.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/odalet.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/odalet.wordpress.com/35/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=odalet.wordpress.com&amp;blog=19103&amp;post=35&amp;subd=odalet&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://odalet.wordpress.com/2007/01/13/log4net-ip-parsing-bug-when-used-with-framework-net-20/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/84b83058bc6f6bf7a2d9a998c3a63854?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">odalet</media:title>
		</media:content>
	</item>
		<item>
		<title>Le dino a bien grandi</title>
		<link>http://odalet.wordpress.com/2007/01/05/le-dino-a-bien-grandi/</link>
		<comments>http://odalet.wordpress.com/2007/01/05/le-dino-a-bien-grandi/#comments</comments>
		<pubDate>Fri, 05 Jan 2007 19:06:07 +0000</pubDate>
		<dc:creator>Olivier</dc:creator>
				<category><![CDATA[fr]]></category>
		<category><![CDATA[misc]]></category>

		<guid isPermaLink="false">http://odalet.wordpress.com/2007/01/05/le-dino-a-bien-grandi/</guid>
		<description><![CDATA[Et voilà le résultat, après quelques jours passés à se gonfler d&#8217;eau :<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=odalet.wordpress.com&amp;blog=19103&amp;post=32&amp;subd=odalet&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Et voilà le résultat, après quelques jours passés à se gonfler d&#8217;eau :</p>
<p><a href="http://odalet.files.wordpress.com/2007/01/windowslivewriterledinoabiengrandi-e827dino11.jpg"><img src="http://odalet.files.wordpress.com/2007/01/windowslivewriterledinoabiengrandi-e827dino2.jpg?w=240&#038;h=208" style="border-width:0;" height="208" width="240" /></a></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/odalet.wordpress.com/32/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/odalet.wordpress.com/32/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/odalet.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/odalet.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/odalet.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/odalet.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/odalet.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/odalet.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/odalet.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/odalet.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/odalet.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/odalet.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/odalet.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/odalet.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/odalet.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/odalet.wordpress.com/32/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=odalet.wordpress.com&amp;blog=19103&amp;post=32&amp;subd=odalet&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://odalet.wordpress.com/2007/01/05/le-dino-a-bien-grandi/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/84b83058bc6f6bf7a2d9a998c3a63854?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">odalet</media:title>
		</media:content>

		<media:content url="http://odalet.files.wordpress.com/2007/01/windowslivewriterledinoabiengrandi-e827dino2.jpg" medium="image" />
	</item>
		<item>
		<title>.NET 3.0 is out!</title>
		<link>http://odalet.wordpress.com/2006/11/09/net-30-is-out/</link>
		<comments>http://odalet.wordpress.com/2006/11/09/net-30-is-out/#comments</comments>
		<pubDate>Wed, 08 Nov 2006 23:21:59 +0000</pubDate>
		<dc:creator>Olivier</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[en]]></category>

		<guid isPermaLink="false">http://odalet.wordpress.com/2006/11/09/net-30-is-out/</guid>
		<description><![CDATA[Great news: .NET Framework 3.0 has been released! Formerly known as WinFx, the .NET framework 3.0 is a set of (3 main) components built on top of the .NET framework 2.0 (this means that this &#8220;3rd&#8221; version is 100% compatible with .NET 2.0: it is pure .NET 2.0 code&#8230;): Windows communication foundation (formerly known as [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=odalet.wordpress.com&amp;blog=19103&amp;post=29&amp;subd=odalet&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Great news: <a href="http://www.netfx3.com/blogs/news_and_announcements/archive/2006/11/06/.NET-Framework-3.0-has-been-released_2100_.aspx">.NET Framework 3.0 has been released!</a></p>
<p>Formerly known as WinFx, the .NET framework 3.0 is a set of (3 main) components built on top of the .NET framework 2.0 (this means that this &#8220;3rd&#8221; version is 100% compatible with .NET 2.0: it is pure .NET 2.0 code&#8230;):</p>
<ul>
<li>Windows communication foundation (formerly known as Indigo)</li>
<li>Windows workflow foundation</li>
<li>Windows presentation foundation (formerly known as Avalon)</li>
<li>and the little last one: Cardspace</li>
</ul>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/odalet.wordpress.com/29/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/odalet.wordpress.com/29/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/odalet.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/odalet.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/odalet.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/odalet.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/odalet.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/odalet.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/odalet.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/odalet.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/odalet.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/odalet.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/odalet.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/odalet.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/odalet.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/odalet.wordpress.com/29/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=odalet.wordpress.com&amp;blog=19103&amp;post=29&amp;subd=odalet&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://odalet.wordpress.com/2006/11/09/net-30-is-out/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/84b83058bc6f6bf7a2d9a998c3a63854?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">odalet</media:title>
		</media:content>
	</item>
		<item>
		<title>Useful memo: Windows messages</title>
		<link>http://odalet.wordpress.com/2006/10/30/useful-memo-windows-messages/</link>
		<comments>http://odalet.wordpress.com/2006/10/30/useful-memo-windows-messages/#comments</comments>
		<pubDate>Mon, 30 Oct 2006 13:57:28 +0000</pubDate>
		<dc:creator>Olivier</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[en]]></category>

		<guid isPermaLink="false">http://odalet.wordpress.com/2006/10/30/useful-memo-windows-messages/</guid>
		<description><![CDATA[Grabbed from this url (may only contain most useful definitions): http://www.groupsrv.com/dotnet/about52848.html: WM_NULL = 0&#215;0000, WM_CREATE = 0&#215;0001, WM_DESTROY = 0&#215;0002, WM_MOVE = 0&#215;0003, WM_SIZE = 0&#215;0005, WM_ACTIVATE = 0&#215;0006, WM_SETFOCUS = 0&#215;0007, WM_KILLFOCUS = 0&#215;0008, WM_ENABLE = 0x000A, WM_SETREDRAW = 0x000B, WM_SETTEXT = 0x000C, WM_GETTEXT = 0x000D, WM_GETTEXTLENGTH = 0x000E, WM_PAINT = 0x000F, WM_CLOSE = [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=odalet.wordpress.com&amp;blog=19103&amp;post=28&amp;subd=odalet&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Grabbed from this url (may only contain most useful definitions): <a href="http://www.groupsrv.com/dotnet/about52848.html">http://www.groupsrv.com/dotnet/about52848.html</a>:</p>
<p>WM_NULL                   = 0&#215;0000,<br />
WM_CREATE                 = 0&#215;0001,<br />
WM_DESTROY                = 0&#215;0002,<br />
WM_MOVE                   = 0&#215;0003,<br />
WM_SIZE                   = 0&#215;0005,<br />
WM_ACTIVATE               = 0&#215;0006,<br />
WM_SETFOCUS               = 0&#215;0007,<br />
WM_KILLFOCUS              = 0&#215;0008,<br />
WM_ENABLE                 = 0x000A,<br />
WM_SETREDRAW              = 0x000B,<br />
WM_SETTEXT                = 0x000C,<br />
WM_GETTEXT                = 0x000D,<br />
WM_GETTEXTLENGTH          = 0x000E,<br />
WM_PAINT                  = 0x000F,<br />
WM_CLOSE                  = 0&#215;0010,<br />
WM_QUERYENDSESSION        = 0&#215;0011,<br />
WM_QUIT                   = 0&#215;0012,<br />
WM_QUERYOPEN              = 0&#215;0013,<br />
WM_ERASEBKGND             = 0&#215;0014,<br />
WM_SYSCOLORCHANGE         = 0&#215;0015,<br />
WM_ENDSESSION             = 0&#215;0016,<br />
WM_SHOWWINDOW             = 0&#215;0018,<br />
WM_CTLCOLOR               = 0&#215;0019,<br />
WM_WININICHANGE           = 0x001A,<br />
WM_SETTINGCHANGE          = 0x001A,<br />
WM_DEVMODECHANGE          = 0x001B,<br />
WM_ACTIVATEAPP            = 0x001C,<br />
WM_FONTCHANGE             = 0x001D,<br />
WM_TIMECHANGE             = 0x001E,<br />
WM_CANCELMODE             = 0x001F,<br />
WM_SETCURSOR              = 0&#215;0020,<br />
WM_MOUSEACTIVATE          = 0&#215;0021,<br />
WM_CHILDACTIVATE          = 0&#215;0022,<br />
WM_QUEUESYNC              = 0&#215;0023,<br />
WM_GETMINMAXINFO          = 0&#215;0024,<br />
WM_PAINTICON              = 0&#215;0026,<br />
WM_ICONERASEBKGND         = 0&#215;0027,<br />
WM_NEXTDLGCTL             = 0&#215;0028,<br />
WM_SPOOLERSTATUS          = 0x002A,<br />
WM_DRAWITEM               = 0x002B,<br />
WM_MEASUREITEM            = 0x002C,<br />
WM_DELETEITEM             = 0x002D,<br />
WM_VKEYTOITEM             = 0x002E,<br />
WM_CHARTOITEM             = 0x002F,<br />
WM_SETFONT                = 0&#215;0030,<br />
WM_GETFONT                = 0&#215;0031,<br />
WM_SETHOTKEY              = 0&#215;0032,<br />
WM_GETHOTKEY              = 0&#215;0033,<br />
WM_QUERYDRAGICON          = 0&#215;0037,<br />
WM_COMPAREITEM            = 0&#215;0039,<br />
WM_GETOBJECT              = 0x003D,<br />
WM_COMPACTING             = 0&#215;0041,<br />
WM_COMMNOTIFY             = 0&#215;0044 ,<br />
WM_WINDOWPOSCHANGING      = 0&#215;0046,<br />
WM_WINDOWPOSCHANGED       = 0&#215;0047,<br />
WM_POWER                  = 0&#215;0048,<br />
WM_COPYDATA               = 0x004A,<br />
WM_CANCELJOURNAL          = 0x004B,<br />
WM_NOTIFY                 = 0x004E,<br />
WM_INPUTLANGCHANGEREQUEST = 0&#215;0050,<br />
WM_INPUTLANGCHANGE        = 0&#215;0051,<br />
WM_TCARD                  = 0&#215;0052,<br />
WM_HELP                   = 0&#215;0053,<br />
WM_USERCHANGED            = 0&#215;0054,<br />
WM_NOTIFYFORMAT           = 0&#215;0055,<br />
WM_CONTEXTMENU            = 0x007B,<br />
WM_STYLECHANGING          = 0x007C,<br />
WM_STYLECHANGED           = 0x007D,<br />
WM_DISPLAYCHANGE          = 0x007E,<br />
WM_GETICON                = 0x007F,<br />
WM_SETICON                = 0&#215;0080,<br />
WM_NCCREATE               = 0&#215;0081,<br />
WM_NCDESTROY              = 0&#215;0082,<br />
WM_NCCALCSIZE             = 0&#215;0083,<br />
WM_NCHITTEST              = 0&#215;0084,<br />
WM_NCPAINT                = 0&#215;0085,<br />
WM_NCACTIVATE             = 0&#215;0086,<br />
WM_GETDLGCODE             = 0&#215;0087,<br />
WM_SYNCPAINT              = 0&#215;0088,<br />
WM_NCMOUSEMOVE            = 0x00A0,<br />
WM_NCLBUTTONDOWN          = 0x00A1,<br />
WM_NCLBUTTONUP            = 0x00A2,<br />
WM_NCLBUTTONDBLCLK        = 0x00A3,<br />
WM_NCRBUTTONDOWN          = 0x00A4,<br />
WM_NCRBUTTONUP            = 0x00A5,<br />
WM_NCRBUTTONDBLCLK        = 0x00A6,<br />
WM_NCMBUTTONDOWN          = 0x00A7,<br />
WM_NCMBUTTONUP            = 0x00A8,<br />
WM_NCMBUTTONDBLCLK        = 0x00A9,<br />
WM_KEYDOWN                = 0&#215;0100,<br />
WM_KEYUP                  = 0&#215;0101,<br />
WM_CHAR                   = 0&#215;0102,<br />
WM_DEADCHAR               = 0&#215;0103,<br />
WM_SYSKEYDOWN             = 0&#215;0104,<br />
WM_SYSKEYUP               = 0&#215;0105,<br />
WM_SYSCHAR                = 0&#215;0106,<br />
WM_SYSDEADCHAR            = 0&#215;0107,<br />
WM_KEYLAST                = 0&#215;0108,<br />
WM_IME_STARTCOMPOSITION   = 0x010D,<br />
WM_IME_ENDCOMPOSITION     = 0x010E,<br />
WM_IME_COMPOSITION        = 0x010F,<br />
WM_IME_KEYLAST            = 0x010F,<br />
WM_INITDIALOG             = 0&#215;0110,<br />
WM_COMMAND                = 0&#215;0111,<br />
WM_SYSCOMMAND             = 0&#215;0112,<br />
WM_TIMER                  = 0&#215;0113,<br />
WM_HSCROLL                = 0&#215;0114,<br />
WM_VSCROLL                = 0&#215;0115,<br />
WM_INITMENU               = 0&#215;0116,<br />
WM_INITMENUPOPUP          = 0&#215;0117,<br />
WM_MENUSELECT             = 0x011F,<br />
WM_MENUCHAR               = 0&#215;0120,<br />
WM_ENTERIDLE              = 0&#215;0121,<br />
WM_MENURBUTTONUP          = 0&#215;0122,<br />
WM_MENUDRAG               = 0&#215;0123,<br />
WM_MENUGETOBJECT          = 0&#215;0124,<br />
WM_UNINITMENUPOPUP        = 0&#215;0125,<br />
WM_MENUCOMMAND            = 0&#215;0126,<br />
WM_CTLCOLORMSGBOX         = 0&#215;0132,<br />
WM_CTLCOLOREDIT           = 0&#215;0133,<br />
WM_CTLCOLORLISTBOX        = 0&#215;0134,<br />
WM_CTLCOLORBTN            = 0&#215;0135,<br />
WM_CTLCOLORDLG            = 0&#215;0136,<br />
WM_CTLCOLORSCROLLBAR      = 0&#215;0137,<br />
WM_CTLCOLORSTATIC         = 0&#215;0138,<br />
WM_MOUSEMOVE              = 0&#215;0200,<br />
WM_LBUTTONDOWN            = 0&#215;0201,<br />
WM_LBUTTONUP              = 0&#215;0202,<br />
WM_LBUTTONDBLCLK          = 0&#215;0203,<br />
WM_RBUTTONDOWN            = 0&#215;0204,<br />
WM_RBUTTONUP              = 0&#215;0205,<br />
WM_RBUTTONDBLCLK          = 0&#215;0206,<br />
WM_MBUTTONDOWN            = 0&#215;0207,<br />
WM_MBUTTONUP              = 0&#215;0208,<br />
WM_MBUTTONDBLCLK          = 0&#215;0209,<br />
WM_MOUSEWHEEL             = 0x020A,<br />
WM_PARENTNOTIFY           = 0&#215;0210,<br />
WM_ENTERMENULOOP          = 0&#215;0211,<br />
WM_EXITMENULOOP           = 0&#215;0212,<br />
WM_NEXTMENU               = 0&#215;0213,<br />
WM_SIZING                 = 0&#215;0214,<br />
WM_CAPTURECHANGED         = 0&#215;0215,<br />
WM_MOVING                 = 0&#215;0216,<br />
WM_DEVICECHANGE           = 0&#215;0219,<br />
WM_MDICREATE              = 0&#215;0220,<br />
WM_MDIDESTROY             = 0&#215;0221,<br />
WM_MDIACTIVATE            = 0&#215;0222,<br />
WM_MDIRESTORE             = 0&#215;0223,<br />
WM_MDINEXT                = 0&#215;0224,<br />
WM_MDIMAXIMIZE            = 0&#215;0225,<br />
WM_MDITILE                = 0&#215;0226,<br />
WM_MDICASCADE             = 0&#215;0227,<br />
WM_MDIICONARRANGE         = 0&#215;0228,<br />
WM_MDIGETACTIVE           = 0&#215;0229,<br />
WM_MDISETMENU             = 0&#215;0230,<br />
WM_ENTERSIZEMOVE          = 0&#215;0231,<br />
WM_EXITSIZEMOVE           = 0&#215;0232,<br />
WM_DROPFILES              = 0&#215;0233,<br />
WM_MDIREFRESHMENU         = 0&#215;0234,<br />
WM_IME_SETCONTEXT         = 0&#215;0281,<br />
WM_IME_NOTIFY             = 0&#215;0282,<br />
WM_IME_CONTROL            = 0&#215;0283,<br />
WM_IME_COMPOSITIONFULL    = 0&#215;0284,<br />
WM_IME_SELECT             = 0&#215;0285,<br />
WM_IME_CHAR               = 0&#215;0286,<br />
WM_IME_REQUEST            = 0&#215;0288,<br />
WM_IME_KEYDOWN            = 0&#215;0290,<br />
WM_IME_KEYUP              = 0&#215;0291,<br />
WM_MOUSEHOVER             = 0x02A1,<br />
WM_MOUSELEAVE             = 0x02A3,<br />
WM_CUT                    = 0&#215;0300,<br />
WM_COPY                   = 0&#215;0301,<br />
WM_PASTE                  = 0&#215;0302,<br />
WM_CLEAR                  = 0&#215;0303,<br />
WM_UNDO                   = 0&#215;0304,<br />
WM_RENDERFORMAT           = 0&#215;0305,<br />
WM_RENDERALLFORMATS       = 0&#215;0306,<br />
WM_DESTROYCLIPBOARD       = 0&#215;0307,<br />
WM_DRAWCLIPBOARD          = 0&#215;0308,<br />
WM_PAINTCLIPBOARD         = 0&#215;0309,<br />
WM_VSCROLLCLIPBOARD       = 0x030A,<br />
WM_SIZECLIPBOARD          = 0x030B,<br />
WM_ASKCBFORMATNAME        = 0x030C,<br />
WM_CHANGECBCHAIN          = 0x030D,<br />
WM_HSCROLLCLIPBOARD       = 0x030E,<br />
WM_QUERYNEWPALETTE        = 0x030F,<br />
WM_PALETTEISCHANGING      = 0&#215;0310,<br />
WM_PALETTECHANGED         = 0&#215;0311,<br />
WM_HOTKEY                 = 0&#215;0312,<br />
WM_PRINT                  = 0&#215;0317,<br />
WM_PRINTCLIENT            = 0&#215;0318,<br />
WM_HANDHELDFIRST          = 0&#215;0358,<br />
WM_HANDHELDLAST           = 0x035F,<br />
WM_AFXFIRST               = 0&#215;0360,<br />
WM_AFXLAST                = 0x037F,<br />
WM_PENWINFIRST            = 0&#215;0380,<br />
WM_PENWINLAST             = 0x038F,<br />
WM_APP                    = 0&#215;8000,<br />
WM_USER                   = 0&#215;0400,<br />
WM_REFLECT                = WM_USER + 0x1c00</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/odalet.wordpress.com/28/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/odalet.wordpress.com/28/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/odalet.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/odalet.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/odalet.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/odalet.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/odalet.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/odalet.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/odalet.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/odalet.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/odalet.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/odalet.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/odalet.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/odalet.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/odalet.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/odalet.wordpress.com/28/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=odalet.wordpress.com&amp;blog=19103&amp;post=28&amp;subd=odalet&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://odalet.wordpress.com/2006/10/30/useful-memo-windows-messages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/84b83058bc6f6bf7a2d9a998c3a63854?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">odalet</media:title>
		</media:content>
	</item>
		<item>
		<title>Impossible de lancer le debugger de Visual Studio 2005</title>
		<link>http://odalet.wordpress.com/2006/09/01/impossible-de-lancer-le-debugger-de-visual-studio-2005/</link>
		<comments>http://odalet.wordpress.com/2006/09/01/impossible-de-lancer-le-debugger-de-visual-studio-2005/#comments</comments>
		<pubDate>Fri, 01 Sep 2006 20:28:18 +0000</pubDate>
		<dc:creator>Olivier</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[fr]]></category>

		<guid isPermaLink="false">http://odalet.wordpress.com/2006/09/01/impossible-de-lancer-le-debugger-de-visual-studio-2005/</guid>
		<description><![CDATA[Le message d&#8217;erreur qui apparaît lorsque l&#8217;on lance un programme depuis Visual Studio 2005 (ou depuis une version Express) est, en français : Handle de liaison invalide ; ce message correspond, en anglais à The binding handle is invalid. Ce problème apparaît lorsque le service Terminal Server est désactivé. Il suffit donc de relancer ce [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=odalet.wordpress.com&amp;blog=19103&amp;post=25&amp;subd=odalet&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Le message d&#8217;erreur qui apparaît lorsque l&#8217;on lance un programme depuis Visual Studio 2005 (ou depuis une version Express) est, en français :<b> Handle de liaison invalide</b> ; ce message correspond, en anglais à <b>The binding handle is invalid</b>.</p>
<p>Ce problème apparaît lorsque le service Terminal Server est désactivé. Il suffit donc de relancer ce service pour que tout rentre dans l&#8217;ordre.</p>
<p>Pour plus de détails, voir les posts suivants (en anglais) :</p>
<p><a href="https://blogs.msdn.com/habibh/archive/2005/11/10/491572.aspx">Troubleshooting the &#8220;The Binding Handle Is Invalid&#8221; error in Visual Studio 2005</a></p>
<p><a href="http://blogs.msdn.com/greggm/archive/2006/01/04/509243.aspx">Explaining &#8216;The Binding Handle Is Invalid&#8217;</a></p>
<p><font color="#0000ff"><a href="http://kenno.wordpress.com/2006/06/25/the-binding-handle-is-invalid-error-in-visual-studio-2005/">“The Binding Handle Is Invalid” error in Visual Studio 2005</a></font></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/odalet.wordpress.com/25/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/odalet.wordpress.com/25/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/odalet.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/odalet.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/odalet.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/odalet.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/odalet.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/odalet.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/odalet.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/odalet.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/odalet.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/odalet.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/odalet.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/odalet.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/odalet.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/odalet.wordpress.com/25/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=odalet.wordpress.com&amp;blog=19103&amp;post=25&amp;subd=odalet&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://odalet.wordpress.com/2006/09/01/impossible-de-lancer-le-debugger-de-visual-studio-2005/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/84b83058bc6f6bf7a2d9a998c3a63854?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">odalet</media:title>
		</media:content>
	</item>
		<item>
		<title>Saving the state of a Graphics object</title>
		<link>http://odalet.wordpress.com/2006/08/23/saving-the-state-of-a-graphics-object/</link>
		<comments>http://odalet.wordpress.com/2006/08/23/saving-the-state-of-a-graphics-object/#comments</comments>
		<pubDate>Wed, 23 Aug 2006 16:32:34 +0000</pubDate>
		<dc:creator>Olivier</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[en]]></category>

		<guid isPermaLink="false">https://odalet.wordpress.com/2006/08/23/saving-the-state-of-a-graphics-object/</guid>
		<description><![CDATA[Today I discovered a new class : GraphicsContainer; it allows you to save the state of a Graphics object (transformation, clipping region, and rendering properties) and to restore it later. This class is used in conjunction with 2 pairs of methods belonging to the Graphics class: BeginContainer saves the state of the graphics object (and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=odalet.wordpress.com&amp;blog=19103&amp;post=21&amp;subd=odalet&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Today I discovered a new class : <a href="http://msdn2.microsoft.com/en-us/library/system.drawing.drawing2d.graphicscontainer.aspx">GraphicsContainer</a>; it allows you to save the state of a Graphics object (transformation, clipping region, and rendering properties) and to restore it later. This class is used in conjunction with 2 pairs of methods belonging to the Graphics class: <a href="http://msdn2.microsoft.com/en-us/library/system.drawing.graphics.begincontainer.aspx">BeginContainer</a> saves the state of the graphics object (and returns a GraphicsContainer object), <a href="http://msdn2.microsoft.com/en-us/library/system.drawing.graphics.endcontainer.aspx">EndContainer</a> restores the state (when provided with a <a href="http://msdn2.microsoft.com/en-us/library/system.drawing.drawing2d.graphicscontainer.aspx">GraphicsContainer</a> object). MSDN provides a sample here: <a href="http://msdn2.microsoft.com/en-us/library/azdschfw.aspx">http://msdn2.microsoft.com/en-us/library/azdschfw.aspx</a>. There exists overloads of <a href="http://msdn2.microsoft.com/en-us/library/system.drawing.graphics.begincontainer.aspx">BeginContainer</a> that accept two rectangles and unit allowing the Graphics object to be applied a new transformation after its state is saved. In the same maneer, but in a simpler way, the <a href="http://msdn2.microsoft.com/en-us/library/system.drawing.graphics.save.aspx">Graphics.Save</a> and <a href="http://msdn2.microsoft.com/en-us/library/system.drawing.graphics.restore.aspx">Graphics.Restore</a> methods do the same job (Honestly, I don&#8217;t understand why these two pairs of methods coexist&#8230;) This led me to write a little helper class allowing to save/restore a Graphics with the <font color="blue">using</font> syntax. Here is how to use this class (it is just a rewritten version of the MSDN): </p>
</p>
<div class="wlWriterSmartContent">
<pre>
<div><span>protected</span><span> </span><span>override</span><span> </span><span>void</span><span> OnPaint(
    System.Windows.Forms.PaintEventArgs e)
{
    Graphics g </span><span>=</span><span> e.Graphics;

    </span><span>//</span><span> Define transformation for container.</span><span>
</span><span>    RectangleF src </span><span>=</span><span> </span><span>new</span><span> RectangleF(
        0f, 0f, 200f, 200f);
    RectangleF dest </span><span>=</span><span> </span><span>new</span><span> RectangleF(
        100f, 100f, 150f, 150f);

    </span><span>using</span><span> (PaintHelper.SaveGraphics(
        g, dest, src, GraphicsUnit.Pixel))
    {
        </span><span>//</span><span> Fill red rectangle in container.</span><span>
</span><span>        g.FillRectangle(Brushes.Red,
            </span><span>0.0F</span><span>, </span><span>0.0F</span><span>, </span><span>200.0F</span><span>, </span><span>200.0F</span><span>);
    }
    </span><span>//</span><span> Fill untransformed rectangle with green.</span><span>
</span><span>    g.FillRectangle(Brushes.Green,
        </span><span>0.0F</span><span>, </span><span>0.0F</span><span>, </span><span>200.0F</span><span>, </span><span>200.0F</span><span>);
}</span></div>
</pre>
</div>
<p>And the source code for the PaintHelper class: </p>
<pre><span>using</span> System;
<span>using</span> System.Drawing;
<span>using</span> System.Drawing.Drawing2D;

<span>namespace</span> Delta.Internals
{
    <span>public</span> <span>static</span> <span>class</span> PaintHelper
    {
        <span>private</span> <span>class</span> GraphicsBackup : IDisposable
        {
            <span>private</span> Graphics graphics = <span>null</span>;
            <span>private</span> GraphicsContainer container = <span>null</span>;

            <span>public</span> GraphicsBackup(Graphics g)
            {
                Init(g);
                container = g.BeginContainer();
            }

            <span>public</span> GraphicsBackup(
                 Graphics g, Rectangle dest, Rectangle src,
                 GraphicsUnit unit)
            {
                container = g.BeginContainer(<span><font color="#000000">
                   </font></span>dest, src, unit);
            }

            <span>public</span> GraphicsBackup(
                 Graphics g, RectangleF dest, RectangleF src,
                 GraphicsUnit unit)
            {
                container = g.BeginContainer(<span>
                   <font color="#000000"> </font></span>dest, src, unit);
            }

            <span>private</span> <span>void</span> Init(Graphics g)
            {
                <span>if</span> (g == <span>null</span>)
                   <span><font color="#000000"> </font>throw</span> <span>new</span> ArgumentNullException("<span>g</span>");
                graphics = g;
            }

            <span>public</span> <span>void</span> Dispose()
            {
                graphics.EndContainer(container);
            }
        }

        <span>public</span> <span>static</span> IDisposable SaveGraphics(Graphics g)
        {
            <span>return</span> <span>new</span> GraphicsBackup(g);
        }

        <span>public</span> <span>static</span> IDisposable SaveGraphics(Graphics g,
            Rectangle dest, Rectangle src,
            GraphicsUnit unit)
        {
            <span>return</span> <span>new</span> GraphicsBackup(
                g, dest, src, unit);
        }

        <span>public</span> <span>static</span> IDisposable SaveGraphics(Graphics g,
            RectangleF dest, RectangleF src,
            GraphicsUnit unit)
        {
            <span>return</span> <span>new</span> GraphicsBackup(
                g, dest, src, unit);
        }
    }
}</pre>
<p>Hope this helps.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/odalet.wordpress.com/21/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/odalet.wordpress.com/21/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/odalet.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/odalet.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/odalet.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/odalet.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/odalet.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/odalet.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/odalet.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/odalet.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/odalet.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/odalet.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/odalet.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/odalet.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/odalet.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/odalet.wordpress.com/21/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=odalet.wordpress.com&amp;blog=19103&amp;post=21&amp;subd=odalet&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://odalet.wordpress.com/2006/08/23/saving-the-state-of-a-graphics-object/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/84b83058bc6f6bf7a2d9a998c3a63854?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">odalet</media:title>
		</media:content>
	</item>
		<item>
		<title>Pattern singleton thread safe en C# : c&#8217;est facile</title>
		<link>http://odalet.wordpress.com/2006/06/20/pattern-singleton-thread-safe-en-c-cest-facile/</link>
		<comments>http://odalet.wordpress.com/2006/06/20/pattern-singleton-thread-safe-en-c-cest-facile/#comments</comments>
		<pubDate>Tue, 20 Jun 2006 20:03:27 +0000</pubDate>
		<dc:creator>Olivier</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[fr]]></category>

		<guid isPermaLink="false">https://odalet.wordpress.com/2006/06/20/pattern-singleton-thread-safe-en-c-cest-facile/</guid>
		<description><![CDATA[Lu ici : http://www.dofactory.com/Patterns/PatternSingleton.aspx Voici la manière classique d&#8217;écrire un pattern singleton thread-safe en C# : class MySingleton { private static MySingleton instance; // Lock synchronization object private static object syncLock = new object(); private MySingleton() { DoSomething(); } public static MySingleton Instance { get { // Support multithreaded applications // through 'Double checked locking' [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=odalet.wordpress.com&amp;blog=19103&amp;post=20&amp;subd=odalet&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Lu ici : <a title="http://www.dofactory.com/Patterns/PatternSingleton.aspx" href="http://www.dofactory.com/Patterns/PatternSingleton.aspx">http://www.dofactory.com/Patterns/PatternSingleton.aspx</a></p>
<p>Voici la manière classique d&#8217;écrire un pattern singleton thread-safe en C# :</p>
<pre>class MySingleton
{
    private static MySingleton instance;

// Lock synchronization object
    private static object syncLock = new object();

private MySingleton() { DoSomething(); }

public static MySingleton Instance
    {
        get
        {
            // Support multithreaded applications
            // through 'Double checked locking'
            // pattern which (once the instance
            // exists) avoids locking each
            // time the method is invoked
            if (instance == null)
            {
                lock (syncLock)
                {
                    if (instance == null)
                        instance = new MySingleton();
                }
            }
            return instance;
        }
    }
}</pre>
<p>Et maintenant, voici la manière &#8220;.NET&#8221; d&#8217;écrire ce même singleton :</p>
<pre>class MySingleton
{
    // Static members are lazily initialized.
    // .NET guarantees thread safety for
    // static initialization
    private static readonly MySingleton instance =
                        new MySingleton();

// Constructor (private)
    private MySingleton() { DoSomething(); }

public static <span style="color:#ff0000;">MySingleton</span> Instance { get { return instance; } }
}</pre>
<p>ça marche parce que &#8220;<span style="color:blue;">private</span> <span style="color:blue;">static</span> <span style="color:blue;">readonly&#8221; </span>entraîne :</p>
<ul>
<li>Initialisation paresseuse</li>
<li>Thread-safety garantie par .NET pour les initialisations statiques.</li>
</ul>
<p>C&#8217;est pas beau ça ?</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/odalet.wordpress.com/20/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/odalet.wordpress.com/20/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/odalet.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/odalet.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/odalet.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/odalet.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/odalet.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/odalet.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/odalet.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/odalet.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/odalet.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/odalet.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/odalet.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/odalet.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/odalet.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/odalet.wordpress.com/20/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=odalet.wordpress.com&amp;blog=19103&amp;post=20&amp;subd=odalet&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://odalet.wordpress.com/2006/06/20/pattern-singleton-thread-safe-en-c-cest-facile/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/84b83058bc6f6bf7a2d9a998c3a63854?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">odalet</media:title>
		</media:content>
	</item>
	</channel>
</rss>
