<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/rss2enclosuresfull.xsl" type="text/xsl" media="screen"?><?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/itemcontent.css" type="text/css" media="screen"?><rss xmlns:blogChannel="http://backend.userland.com/blogChannelModule" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
  <channel>
    <title>[ Simon Boigelot World ]</title>
    <description>Het laboratoire van un programmeur fool</description>
    <link>http://www.simonboigelot.com/</link>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <generator>BlogEngine.Net Syndication Generator 1.0.0.0 (http://dotnetblogengine.net/)</generator>
    <language>fr-FR</language>
    <blogChannel:blogRoll>http://www.simonboigelot.com/opml.axd</blogChannel:blogRoll>
    <blogChannel:blink>http://feeds.feedburner.com/SimonBoigelotWorld</blogChannel:blink>
    <dc:creator>Boigelot Simon</dc:creator>
    <dc:description>Het laboratoire van un programmeur fool</dc:description>
    <dc:title>[ Simon Boigelot World ]</dc:title>
    <geo:lat>0.000000</geo:lat>
    <geo:long>0.000000</geo:long>
    <itunes:explicit>no</itunes:explicit><itunes:subtitle>Het laboratoire van un programmeur fool</itunes:subtitle><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/SimonBoigelotWorld" type="application/rss+xml" /><item>
      <title>Architecture simplifi&amp;eacute;e de BizTalk</title>
      <description>&lt;p&gt;Dans cet article vous trouverez une première compréhension générale de l'architecture de BizTalk. &lt;p&gt;Cette compréhension est nécessaire avant de nous plonger dans le développement. &lt;p&gt;BizTalk permet de mettre en place des flux de données à partir d’une origine A vers un destination B. Mais que ce passe-t-il entre ces deux points ? Tel est la question à laquelle nous allons répondre. &lt;p&gt;Voici une vue très simplifiée de l’architecture de BizTalk : &lt;p&gt;&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/ArchitecturesimplifiedeBizTalk_41DA/image_2.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="196" alt="image" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/ArchitecturesimplifiedeBizTalk_41DA/image_thumb.png" width="447" border="0"&gt;&lt;/a&gt;  &lt;blockquote&gt; &lt;p&gt;1. Les données sont reçues par un &lt;b&gt;Receive Port&lt;/b&gt;. Les receive ports ne font que transmettre les données en format binaire, sans se soucier du contenu de ce qu’ils transportent. &lt;p&gt;2. Elles sont acheminées vers une base de données centrale par une &lt;b&gt;Receive Pipeline.&lt;/b&gt; C’est lors de cette phase du transport que le mapping sera appliqué aux données binaires pour fournir un format XML comprenant des &lt;b&gt;promoted properties&lt;/b&gt;. &lt;p&gt;3. Ensuite, si des orchestrations sont configurées pour agir sur le type de message reçu, elles seront instanciées. Une orchestration est une étape du processus métier qui est prise en charge par BizTalk. &lt;p&gt;4. Les &lt;b&gt;Send Pipelines&lt;/b&gt; sont l’exact opposé des Receive Pipelines. Ces pipelines vont prendre les données sous format XML et les convertir dans le format destination désiré. Encore une foi grâce à un mapping. &lt;p&gt;5. Les données sont enfin envoyées au destinataire par un &lt;b&gt;Send Port&lt;/b&gt; qui ne se charge que de transmettre les informations binaires au bon endroit.&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;Pour savoir quelle est l’étape à appliquer à un message à un moment donné, BizTalk garde un fichier supplémentaire, le fichier de contexte. &lt;p&gt;Ce fichier de contexte possède de nombreuses information tel que : &lt;blockquote&gt; &lt;p&gt;· Le type du fichier message&lt;br&gt;· L’historique complet du fichier à travers le processus BizTalk&lt;br&gt;· Les erreurs éventuelles survenues&lt;br&gt;· Les différentes promoted properties&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;C’est sur les valeurs contenues dans ce fichier de contexte que les différentes parties du flux BizTalk, les &lt;b&gt;artefacts&lt;/b&gt;, peuvent souscrire. &lt;p&gt;Ainsi nous allons pouvoir créer, par exemple, une Send Pipeline et la souscrire aux messages ayant un schéma correspondant au XSD « monSchema.xsd » et provenant de l’orchestration « monOrchestration ». &lt;p&gt;Le moteur interne de BizTalk créera alors toutes les suscriptions T-SQL nécessaire pour instancier cette Send Pipeline à chaque foi que des données correspondante seront insérée dans la MessageBox. &lt;p&gt;La &lt;b&gt;MessageBox&lt;/b&gt; est le cœur de BizTalk. Elle repose sous SQL-Server ce qui nous offre beaucoup de possibilité quand à la fragmentation de cette base de donnée. &lt;p&gt;Lorsque qu’un fichier est reçu par BizTalk on parle de message. Les messages peuvent-être dupliqué, ainsi si plusieurs artefacts ont une suscription qui correspond à un même message, chacun de ces artefacts recevra une copie autonome du message. &lt;p&gt;Maintenant que nous avons une vue globale de l’architecture de BizTalk, nous allons pouvoir nous intéresser en détail à chaque artéfact. &lt;h2&gt;Port&lt;/h2&gt; &lt;p&gt;Un port est la représentation logique d’une communication physique par laquelle BizTalk reçoit et envoi des messages. &lt;p&gt;Chaque port est un conteneur qui possède toutes les informations nécessaires à l’établissement d’un canal de communication. &lt;p&gt;L’élément principal d’un port est l’adaptateurs qu’il utilise. Chaque type de communication possède son adaptateur. &lt;p&gt;Par exemple, un Send Port utilisant le protocole FTP possèdera un adaptateur FTP ainsi que les configurations suivantes : &lt;blockquote&gt; &lt;p&gt;· Ip de contact&lt;br&gt;· Login&lt;br&gt;· Password&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;Pour ne citer que les plus évidentes. &lt;h3&gt;Receive Port&lt;/h3&gt; &lt;p&gt;Les receive ports ont pour particularité d’être des conteneurs de Port. Ainsi un unique reveive port peut en faite être associé à plusieurs configurations différentes, nommée Receive Location. &lt;p&gt;Ainsi un receive port attendant des ordres d’achat pourra être composé de plusieurs receive locations : &lt;blockquote&gt; &lt;p&gt;· La première attendant des fichiers sur un FTP&lt;br&gt;· La seconde sur le système de fichier d’un serveur&lt;br&gt;· La troisième par mail&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;Quelque soit l’origine du fichier reçu, il sera traité de la même manière dans la suite du flux de donnée. &lt;h3&gt;Send Port&lt;/h3&gt; &lt;h5&gt;En contradiction avec les receive port, les send ports eux ne peuvent contenir qu’un unique port de destination.&lt;/h5&gt; &lt;p&gt;Pour palier à ce désavantage, BizTalk offre la possibilité de crée des SendPortGroup, contenant plusieurs Send Port. &lt;h3&gt;Logical Port&lt;/h3&gt; &lt;p&gt;Lors de la création d’une orchestration, le programmeur ne sait pas forcément d’où lui viendra les données, ni où il devra les envoyer ensuite. &lt;p&gt;C’est dans ces cas précis qu’interviennent les ports logiques. &lt;p&gt;Les ports logiques ne doivent être liés à des ports physiques qu’au moment du déploiement de l’application. &lt;h3&gt;Dynamic Send Port&lt;/h3&gt; &lt;p&gt;Ces send ports particulier permettent de définir la destination des messages au moment de l’exécution au lieu de le faire lors déploiement de l’application. &lt;p&gt;Cette destination doit être définie par déduction sur des promoted properties. &lt;h2&gt;Adaptateur&lt;/h2&gt; &lt;p&gt;Les adaptateurs sont les interfaces de communication de BizTalk autant en entrée qu’en sortie. &lt;p&gt;La plupart du temps, les adaptateurs ne sont que des interfaces de communication basée sur un protocole de transport donné. Ils n’ont donc aucune compréhension interne des données qu’ils transportent. &lt;p&gt;Leur unique utilité est de nourrir et de délester la machinerie de BizTalk. &lt;p&gt;Dans le cas d’adaptateur de réception, deux modes principaux existent : &lt;blockquote&gt; &lt;p&gt;· Le pooling : de temps à autre l’adaptateur vérifie le contenu d’un répertoire (ou autre) pour vérifier si des messages attendu par BizTalk ne s’y trouve pas. C’est le cas du « &lt;b&gt;File System Adaptater&lt;/b&gt; ».&lt;br&gt;· L’écoute : l’adaptateur est en attente d’un événement en provenance su monde extérieur pour se réveiller.&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;Lorsqu’un message est reçu par un adaptateur, contrairement à ce que l’on dessine habituellement, il n’est pas envoyé directement à une receive pipeline mais passe d’abord par la MessageBox. &lt;p&gt;C’est le « &lt;b&gt;Message Engine&lt;/b&gt; » de BizTalk qui à la charge de transmettre ce message de la MessageBox a la receive pipeline appropriée. &lt;p&gt;Un adaptateur des plus important est le « &lt;b&gt;SQL Adaptater&lt;/b&gt; », en effet, la MessageBox reposant sur une base de données SQL Server, chaque communication interne à BizTalk repose sur cet adaptateur. &lt;h2&gt;Pipeline&lt;/h2&gt; &lt;p&gt;Les pipelines ont pour fonction d’effectuer des traitements de données sur les messages entrants ou les messages sortants. Cet aussi cet artéfact qui à comme responsabilité la validation de ces messages. &lt;p&gt;Par traitements de données ont entent principalement tout ce qui est sécurité (cryptage/décryptage, signature). &lt;p&gt;BizTalk fournit 4 pipelines basiques qui permettent de remplir toutes les fonctions les plus couramment utilisées : &lt;p&gt;· Receive Pipeline &lt;blockquote&gt; &lt;p&gt;o XmlReceive : permet de recevoir des messages XML et de les valider&lt;br&gt;o PassThruReceive : permet de recevoir des messages sous format flat file&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;· SendPipeline &lt;blockquote&gt; &lt;p&gt;o XmdTransmit : permet d’envoyer des messages XML et de les valider&lt;br&gt;o PassThruTransmit : permet d’envoyer des messages sous format flat file&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;Comme son nom l’indique, un pipeline est un suivit d’opérations les unes aux suites des autres. Dans un pipeline l’ordre des opérations est très important, en effet, a quoi bon par exemple essayer de valider un fichier XML qui n’a pas été décrypté. &lt;p&gt;Pour simplifier la mise en place de pipeline, BizTalk à séparé en grands groupes les type d’opérations pouvant être effectuée sur un message. &lt;p&gt;&lt;strong&gt;Receive Pipeline Operation Group :&lt;/strong&gt; &lt;blockquote&gt; &lt;p&gt;1. Décode : cette étape sert à décoder les messages d’un format externe à un format lisible par les autres composants. Le plus commun des cas de décode est sans nul doute le décryptage.&lt;br&gt;2. Désassemble : en fonction du type de message, cette étape va soit traduire le message d’origine en un message XML, soit découper le message en plusieurs sous-messages plus conforme à l’implémentation du flux.&lt;br&gt;3. Validation : valide un message à partir d’un schéma.&lt;br&gt;4. Résoudre les partenaires : cette étape est principalement utilisée pour certifier la provenance des messages reçus.&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;&lt;strong&gt;Send Pipeline Operation Group :&lt;/strong&gt; &lt;blockquote&gt; &lt;p&gt;1. Pré-assemble : cette étape et le dernier point de modifications des données par le flux BizTalk, généralement utilisée pour faire des transformations de dernière minute sur le XML interne de BizTalk avant qu’il ne soit transformé en flat file.&lt;br&gt;2. Assemble : utilisation d’un schéma pour transformer un ou plusieurs messages en un message respectant le format convenant au destinataire.&lt;br&gt;3. Encore : à l’inverse de décode, cette phase est utilisée pour crypter les données. (Un autre exemple est la compression des données)&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;De nombreux composant de pipelines effectuant ce genre d’opération sont inclus dans BizTalk mais il est toujours possible d’écrire nos propres composants ou d’en acheter de nouveau, comme d’habitude. &lt;h2&gt;Orchestration&lt;/h2&gt; &lt;p&gt;Les orchestrations permettent au développeur BizTalk d’implémenter un processus métier à travers un outil de dessin : l’Orchestration Designer. &lt;p&gt;Cet outil permet d’exprimer le processus métier via une série de forme glissée sur la surface de dessin à partir de la boîte à outil de Visual Studio. &lt;p&gt;A travers ces dessins, tout le framework .Net ainsi que le framework BizTalk sont accessible. &lt;p&gt;Il est ainsi possible de laisser libre cours à son implémentation du processus métier sans pour autant devoir écrire plusieurs programmes fastidieux pour gérer chaque étape de ce processus. &lt;p&gt;Les orchestrations, tout comme les autres artéfacts de BizTalk, souscrivent à certain messages arrivant dans la MessageBox et sont instanciée par celle-ci lorsque l’un deux arrive. &lt;p&gt;Ces orchestrations sont alors capable, par exemple de gérer des exception tel que : « A la réception d’un ordre d’achat j’envoie une facture, mais si je n’ai pas d’accusé de réception avant 2 jours, j’annule l’ordre » &lt;p&gt;Encore une foi, les « &lt;b&gt;shape d’orchestration&lt;/b&gt; », ces fameuses formes servant à dessiner sont nombreuses mais il est toujours possible de créer les nôtre.&lt;img src="http://feeds.feedburner.com/~r/SimonBoigelotWorld/~4/335667292" height="1" width="1"/&gt;</description>
      <link>http://feeds.feedburner.com/~r/SimonBoigelotWorld/~3/335667292/post.aspx</link>
      <author>Togis</author>
      <comments>http://www.simonboigelot.com/post/Architecture-simplifieacute;e-de-BizTalk.aspx#comment</comments>
      <guid isPermaLink="false">http://www.simonboigelot.com/post.aspx?id=88c93968-4ba7-4b31-8876-d478a8b1081a</guid>
      <pubDate>Tue, 15 Jul 2008 04:41:35 +0200</pubDate>
      <category>BizTalk</category>
      <dc:publisher>Togis</dc:publisher>
      <pingback:server>http://www.simonboigelot.com/pingback.axd</pingback:server>
      <pingback:target>http://www.simonboigelot.com/post.aspx?id=88c93968-4ba7-4b31-8876-d478a8b1081a</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://www.simonboigelot.com/trackback.axd?id=88c93968-4ba7-4b31-8876-d478a8b1081a</trackback:ping>
      <wfw:comment>http://www.simonboigelot.com/post/Architecture-simplifieacute;e-de-BizTalk.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.simonboigelot.com/syndication.axd?post=88c93968-4ba7-4b31-8876-d478a8b1081a</wfw:commentRss>
    <feedburner:origLink>http://www.simonboigelot.com/post.aspx?id=88c93968-4ba7-4b31-8876-d478a8b1081a</feedburner:origLink></item>
    <item>
      <title>Cr&amp;eacute;er une orchestration BizTalk avec Visual Studio</title>
      <description>&lt;p&gt;
Dans cet exercice nous allons apprendre &amp;agrave; cr&amp;eacute;er des orchestrations gr&amp;acirc;ce &amp;agrave; l&amp;rsquo;Orchestration Designer de BizTalk. 
&lt;/p&gt;
&lt;p&gt;
L&amp;rsquo;orchestration que nous allons cr&amp;eacute;er va faire exactement la m&amp;ecirc;me chose que les filtres des Send Ports du chapitre pr&amp;eacute;c&amp;eacute;dent. Cependant gardez &amp;agrave; l&amp;rsquo;esprit que les orchestrations ont bien plus de capacit&amp;eacute;s, mais il faut bien commencer petit. 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; Ouvrez Visual Studio 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; Cr&amp;eacute;er un nouveau projet &amp;laquo; &lt;strong&gt;Empty Biztalk Server Project&lt;/strong&gt; &amp;raquo; du nom de &amp;laquo; &lt;strong&gt;LabOrchestration&lt;/strong&gt; &amp;raquo; 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; N&amp;rsquo;oubliez pas de directement changer le nom de d&amp;eacute;ploiement du projet pour &amp;laquo; &lt;strong&gt;LabOrchestration&lt;/strong&gt; &amp;raquo; et de lui assigner une clef de signature. 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; Ajoutez 1 sch&amp;eacute;ma au projet :&lt;br /&gt;
&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_26.png"&gt;&lt;img style="border: 0px" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_thumb_12.png" border="0" alt="image" width="244" height="89" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; Pour des raisons &amp;eacute;ducative, ne faites pas de &amp;laquo; &lt;strong&gt;NombrePage&lt;/strong&gt; &amp;raquo; un &amp;laquo; &lt;strong&gt;xs :int&lt;/strong&gt; &amp;raquo; mais gardez le en &amp;laquo; &lt;strong&gt;xs :string&lt;/strong&gt; &amp;raquo; 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; Pour pouvoir utiliser ce champ lors d&amp;rsquo;une orchestration, il doit recevoir une promotion particuli&amp;egrave;re nomm&amp;eacute;e &amp;laquo; &lt;strong&gt;Distinguished Field&lt;/strong&gt; &amp;raquo;. 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; Pour ce faire, cliquez sur le champ avec le bouton droit de la souris et s&amp;eacute;lectionnez &amp;laquo; &lt;strong&gt;Promote &lt;/strong&gt;&lt;strong&gt;&amp;agrave; Show Promotion&lt;/strong&gt; &amp;raquo; 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_2.png"&gt;&lt;img style="border: 0px" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_thumb.png" border="0" alt="image" width="244" height="67" /&gt;&lt;/a&gt;&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; Dans la bo&amp;icirc;te de dialogue qui s&amp;rsquo;ouvre vous trouvez la possibilit&amp;eacute; d&amp;rsquo;ajouter le champ &amp;laquo; &lt;strong&gt;NombrePage&lt;/strong&gt; &amp;raquo; aux &amp;laquo; &lt;strong&gt;Distinguished Fields&lt;/strong&gt; &amp;raquo;. 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; Cliquez avec le bouton droit de la souris sur votre projet, s&amp;eacute;lectionnez &amp;laquo; &lt;strong&gt;Add &lt;/strong&gt;&lt;strong&gt;&amp;agrave;&lt;/strong&gt;&lt;strong&gt; New Item&amp;hellip;&lt;/strong&gt; &amp;raquo; 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; Dans la bo&amp;icirc;te de dialogue &amp;laquo; &lt;strong&gt;Add New Item&lt;/strong&gt; &amp;raquo;, sous &amp;laquo; &lt;strong&gt;Orchestration Files&lt;/strong&gt; &amp;raquo; choisissez &amp;laquo; &lt;strong&gt;BizTalk Orchestration&lt;/strong&gt; &amp;raquo; et nommez la &amp;laquo; &lt;strong&gt;OrchestrationTrieLivre &lt;/strong&gt;&amp;raquo; 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; L&amp;rsquo;&amp;eacute;diteur d&amp;rsquo;orchestration s&amp;rsquo;ouvre dans Visual Studio. 
&lt;/p&gt;
&lt;p&gt;
Une orchestration commence toujours par la r&amp;eacute;ception d&amp;rsquo;un message, soit par suscription, soit par appel &amp;agrave; partir d&amp;rsquo;une autre orchestration. 
&lt;/p&gt;
&lt;p&gt;
Dans la bo&amp;icirc;te &amp;agrave; outil de Visual Studio vous trouverez tous les &amp;laquo; &lt;strong&gt;Shapes&lt;/strong&gt; &amp;raquo; de base utilis&amp;eacute;s lors de la cr&amp;eacute;ation d&amp;rsquo;une nouvelle orchestration. 
&lt;/p&gt;
&lt;p&gt;
Passons en revue les plus int&amp;eacute;ressants :
&lt;/p&gt;
&lt;table border="1" cellspacing="0" cellpadding="2" width="400"&gt;
	&lt;tbody&gt;
		&lt;tr&gt;
			&lt;td width="200" valign="top"&gt;&lt;strong&gt;Shape&lt;/strong&gt;&lt;/td&gt;
			&lt;td width="200" valign="top"&gt;
			&lt;p&gt;
			&lt;strong&gt;Explication&lt;/strong&gt;
			&lt;/p&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td width="200" valign="top"&gt;&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_28.png"&gt;&lt;img style="border: 0px" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_thumb_13.png" border="0" alt="image" width="209" height="22" /&gt;&lt;/a&gt; &lt;/td&gt;
			&lt;td width="200" valign="top"&gt;
			&lt;p&gt;
			Action d&amp;rsquo;envoyer un message &amp;agrave; travers un Send Port
			&lt;/p&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td width="200" valign="top"&gt;&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_30.png"&gt;&lt;img style="border: 0px" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_thumb_14.png" border="0" alt="image" width="214" height="30" /&gt;&lt;/a&gt; &lt;/td&gt;
			&lt;td width="200" valign="top"&gt;
			&lt;p&gt;
			Action de recevoir un message en provenance d&amp;rsquo;un Receive Port.
			&lt;/p&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td width="200" valign="top"&gt;&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_32.png"&gt;&lt;img style="border: 0px" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_thumb_15.png" border="0" alt="image" width="216" height="37" /&gt;&lt;/a&gt; &lt;/td&gt;
			&lt;td width="200" valign="top"&gt;
			&lt;p&gt;
			Repr&amp;eacute;sentation d&amp;rsquo;un port au niveau d&amp;rsquo;une orchestration, il s&amp;rsquo;agit ici d&amp;rsquo;un port logique qui devra &amp;ecirc;tre li&amp;eacute; &amp;agrave; un port physique lors de la configuration de l&amp;rsquo;orchestration. (Apr&amp;egrave;s d&amp;eacute;ploiement)
			&lt;/p&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td width="200" valign="top"&gt;&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_34.png"&gt;&lt;img style="border: 0px" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_thumb_16.png" border="0" alt="image" width="210" height="27" /&gt;&lt;/a&gt; &lt;/td&gt;
			&lt;td width="200" valign="top"&gt;
			&lt;p&gt;
			Permet d&amp;rsquo;appliquer un map XSLT sur un message
			&lt;/p&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td width="200" valign="top"&gt;&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_36.png"&gt;&lt;img style="border: 0px" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_thumb_17.png" border="0" alt="image" width="215" height="28" /&gt;&lt;/a&gt; &lt;/td&gt;
			&lt;td width="200" valign="top"&gt;
			&lt;p&gt;
			Action de construire un nouveau message sur base d&amp;rsquo;un sch&amp;eacute;ma
			&lt;/p&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td width="200" valign="top"&gt;&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_38.png"&gt;&lt;img style="border: 0px" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_thumb_18.png" border="0" alt="image" width="214" height="52" /&gt;&lt;/a&gt; &lt;/td&gt;
			&lt;td width="200" valign="top"&gt;
			&lt;p&gt;
			Permet &amp;agrave; une orchestration d&amp;rsquo;en invoquer d&amp;rsquo;autre. Call est synchrone, Start asynchrone.
			&lt;/p&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td width="200" valign="top"&gt;&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_40.png"&gt;&lt;img style="border: 0px" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_thumb_19.png" border="0" alt="image" width="214" height="27" /&gt;&lt;/a&gt; &lt;/td&gt;
			&lt;td width="200" valign="top"&gt;
			&lt;p&gt;
			Permet de faire appel au Business Rule Engine.
			&lt;/p&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td width="200" valign="top"&gt;&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_42.png"&gt;&lt;img style="border: 0px" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_thumb_20.png" border="0" alt="image" width="211" height="30" /&gt;&lt;/a&gt; &lt;/td&gt;
			&lt;td width="200" valign="top"&gt;
			&lt;p&gt;
			Permet l&amp;rsquo;appel d&amp;rsquo;un script .Net
			&lt;/p&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td width="200" valign="top"&gt;&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_44.png"&gt;&lt;img style="border: 0px" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_thumb_21.png" border="0" alt="image" width="214" height="36" /&gt;&lt;/a&gt; &lt;/td&gt;
			&lt;td width="200" valign="top"&gt;
			&lt;p&gt;
			Repr&amp;eacute;sentation d&amp;rsquo;un &amp;laquo; If-then-else &amp;raquo;
			&lt;/p&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td width="200" valign="top"&gt;&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_46.png"&gt;&lt;img style="border: 0px" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_thumb_22.png" border="0" alt="image" width="212" height="29" /&gt;&lt;/a&gt; &lt;/td&gt;
			&lt;td width="200" valign="top"&gt;
			&lt;p&gt;
			Permet &amp;agrave; l&amp;rsquo;orchestration de marquer un temps de pause
			&lt;/p&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td width="200" valign="top"&gt;&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_48.png"&gt;&lt;img style="border: 0px" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_thumb_23.png" border="0" alt="image" width="212" height="28" /&gt;&lt;/a&gt; &lt;/td&gt;
			&lt;td width="200" valign="top"&gt;
			&lt;p&gt;
			Multithreading interne aux orchestrations
			&lt;/p&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td width="200" valign="top"&gt;&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_50.png"&gt;&lt;img style="border: 0px" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_thumb_24.png" border="0" alt="image" width="211" height="31" /&gt;&lt;/a&gt; &lt;/td&gt;
			&lt;td width="200" valign="top"&gt;
			&lt;p&gt;
			Repr&amp;eacute;sentation d&amp;rsquo;un boucle &amp;laquo; Tant que (condition) &amp;raquo;
			&lt;/p&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td width="200" valign="top"&gt;&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_52.png"&gt;&lt;img style="border: 0px" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_thumb_25.png" border="0" alt="image" width="213" height="51" /&gt;&lt;/a&gt; &lt;/td&gt;
			&lt;td width="200" valign="top"&gt;
			&lt;p&gt;
			Shapes utilis&amp;eacute;e pour la gestion des erreurs
			&lt;/p&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td width="200" valign="top"&gt;&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_54.png"&gt;&lt;img style="border: 0px" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_thumb_26.png" border="0" alt="image" width="212" height="34" /&gt;&lt;/a&gt; &lt;/td&gt;
			&lt;td width="200" valign="top"&gt;
			&lt;p&gt;
			Met une Orchestration en attentent de l&amp;rsquo;action d&amp;rsquo;un administrateur.
			&lt;/p&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td width="200" valign="top"&gt;&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_56.png"&gt;&lt;img style="border: 0px" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_thumb_27.png" border="0" alt="image" width="213" height="32" /&gt;&lt;/a&gt; &lt;/td&gt;
			&lt;td width="200" valign="top"&gt;
			&lt;p&gt;
			Met fin &amp;agrave; l&amp;rsquo;orchestration
			&lt;/p&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
	&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;
Notre orchestration doit recevoir un Livre et l&amp;rsquo;envoyer &amp;agrave; deux ports diff&amp;eacute;rents selon le nombre de Page qu&amp;rsquo;il contient. 
&lt;/p&gt;
&lt;p&gt;
Pour ce faire, il nous faudra donc : 
&lt;/p&gt;
&lt;p&gt;
&amp;Oslash; 3 Ports Logique (1 receive, 2 send) 
&lt;/p&gt;
&lt;p&gt;
&amp;Oslash; 1 Receive Shape 
&lt;/p&gt;
&lt;p&gt;
&amp;Oslash; 2 Send Shapes 
&lt;/p&gt;
&lt;p&gt;
&amp;Oslash; 1 Decide Shape 
&lt;/p&gt;
&lt;p&gt;
Ajoutez le premier Port Logique &amp;agrave; l&amp;rsquo;orchestration en le glissant sur le &amp;laquo; &lt;strong&gt;Port Surface &lt;/strong&gt;&amp;raquo; de gauche du designer. 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_4.png"&gt;&lt;img style="border: 0px" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_thumb_1.png" border="0" alt="image" width="244" height="86" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; Un assistant de configuration de ce port s&amp;rsquo;ouvre. Cliquez sur &lt;strong&gt;Next&lt;/strong&gt;. 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; Le nom de ce port est &amp;laquo; &lt;strong&gt;OrchRcvPortLivre&lt;/strong&gt; &amp;raquo;. Cliquez sur &lt;strong&gt;Next&lt;/strong&gt;. 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; L&amp;rsquo;assistant nous demande de choisir ou de cr&amp;eacute;e un &amp;laquo; &lt;strong&gt;Type de port&lt;/strong&gt; &amp;raquo; pour notre nouveau port logique. En effet, on ne peut lier un port physique &amp;agrave; un port logique que si, et seulement si, ses caract&amp;eacute;ristiques son similaire. Le &amp;laquo; &lt;strong&gt;Type de port&lt;/strong&gt; &amp;raquo; est le conteneur des caract&amp;eacute;ristiques de notre port logique. N&amp;rsquo;en ayant encore jamais cr&amp;eacute;&amp;eacute; auparavant dans ce projet, cr&amp;eacute;ons en un. 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; Choisissez &amp;laquo; &lt;strong&gt;OrchRcvPortLivreType&lt;/strong&gt; &amp;raquo; comme nom de Type 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; &amp;laquo; &lt;strong&gt;One-Way&lt;/strong&gt; &amp;raquo; et &amp;laquo; &lt;strong&gt;Internal &lt;/strong&gt;&amp;raquo; comme caract&amp;eacute;ristiques. Cliquez sur &lt;strong&gt;Next&lt;/strong&gt;. 
&lt;/p&gt;
&lt;p&gt;
Dans la page suivante de cet assistant, on nous propose de sp&amp;eacute;cifier le sens du port et on nous offre le choix entre plusieurs possibilit&amp;eacute;s quant-&amp;agrave; son impl&amp;eacute;mentation physique. 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_6.png"&gt;&lt;img style="border: 0px" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_thumb_2.png" border="0" alt="image" width="244" height="83" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;&amp;laquo; &lt;strong&gt;Port binding&lt;/strong&gt; &amp;raquo; offre 3 possibilit&amp;eacute;s :&lt;br /&gt;
&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;Oslash; &lt;strong&gt;Sp&amp;eacute;cify now&lt;/strong&gt;: cr&amp;eacute;e directement un port physique sur base des informations du port logique 
&lt;/p&gt;
&lt;p&gt;
&amp;Oslash; &lt;strong&gt;Sp&amp;eacute;cify later&lt;/strong&gt; : permet au d&amp;eacute;veloppeur de lier ce port logique &amp;agrave; un port physique plus tard, apr&amp;egrave;s le d&amp;eacute;ploiement. 
&lt;/p&gt;
&lt;p&gt;
&amp;Oslash; &lt;strong&gt;Direct&lt;/strong&gt; : Ce port logique prend sa source soit directement sur la MessageBox de BizTalk, soit d&amp;rsquo;une autre Orchestration, soit de cette orchestration elle-m&amp;ecirc;me. (Cette derni&amp;egrave;re option peut para&amp;icirc;tre &amp;eacute;trange mais il ne s&amp;rsquo;agit en faite que de la possibilit&amp;eacute; de cr&amp;eacute;er des Orchestration r&amp;eacute;cursives) 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; Choisissez &amp;laquo; &lt;strong&gt;Sp&amp;eacute;cify later&lt;/strong&gt; &amp;raquo;. Cliquez sur &lt;strong&gt;Next.&lt;/strong&gt; 
&lt;/p&gt;
&lt;p&gt;
Cliquez sur le port nouvellement ajout&amp;eacute; et ouvrez ses propri&amp;eacute;t&amp;eacute;s. 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_8.png"&gt;&lt;img style="border: 0px" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_thumb_3.png" border="0" alt="image" width="244" height="129" /&gt;&lt;/a&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&amp;middot; Remarquez que BizTalk demande que vous lui sp&amp;eacute;cifier quel sch&amp;eacute;ma sera utilis&amp;eacute; pour la validation des message entrant par ce port. 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; Choisissez &amp;laquo;&lt;strong&gt; LabOrchestration.Live&lt;/strong&gt; &amp;raquo; 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_10.png"&gt;&lt;img style="border: 0px" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_thumb_4.png" border="0" alt="image" width="244" height="86" /&gt;&lt;/a&gt;&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; Ajouter un &amp;laquo; &lt;strong&gt;Receive Shape&lt;/strong&gt; &amp;raquo; &amp;agrave; l&amp;rsquo;Orchestration en le glissant sur la surface de dessin. 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_12.png"&gt;&lt;img style="border: 0px" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_thumb_5.png" border="0" alt="image" width="244" height="73" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; Liez ce &amp;laquo; &lt;strong&gt;Receive&lt;/strong&gt; &lt;strong&gt;Shape&lt;/strong&gt; &amp;raquo; &amp;agrave; votre port &amp;laquo; &lt;strong&gt;OrchRcvPortLivre&lt;/strong&gt; &amp;raquo; 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_14.png"&gt;&lt;img style="border: 0px" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_thumb_6.png" border="0" alt="image" width="244" height="109" /&gt;&lt;/a&gt;&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; Ajoutez un &amp;laquo; &lt;strong&gt;Decide Shape&lt;/strong&gt; &amp;raquo; &amp;agrave; l&amp;rsquo;orchestration : 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_18.png"&gt;&lt;img style="border: 0px" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_thumb_8.png" border="0" alt="image" width="244" height="194" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; S&amp;eacute;lectionnez le point d&amp;rsquo;exclamation et cliquez sur &lt;strong&gt;&amp;laquo; No Expression, Click&amp;hellip;&lt;/strong&gt; &amp;raquo; 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_16.png"&gt;&lt;img style="border: 0px" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_thumb_7.png" border="0" alt="image" width="244" height="45" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; Une bo&amp;icirc;te de script .Net s&amp;rsquo;ouvre, c&amp;rsquo;est ici que nous allons d&amp;eacute;finir la condition de notre &amp;laquo; if-then-else &amp;raquo;. 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; Remplissez-la par : &lt;br /&gt;
&amp;laquo; System.Int32.Parse(Message_1.NombrePage) &amp;lt; 500 &amp;raquo;&lt;br /&gt;
il s&amp;rsquo;agit de notre condition. 
&lt;/p&gt;
&lt;p&gt;
&amp;middot;Ajoutez un Port logique dans le &amp;laquo; &lt;strong&gt;Port Surface &lt;/strong&gt;&amp;raquo; de gauche. 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_20.png"&gt;&lt;img style="border: 0px" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_thumb_9.png" border="0" alt="image" width="244" height="80" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; Ajoutez un Port logique dans le &amp;laquo; &lt;strong&gt;Port Surface &lt;/strong&gt;&amp;raquo; de droite. 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_22.png"&gt;&lt;img style="border: 0px" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_thumb_10.png" border="0" alt="image" width="244" height="84" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; Ajouter un &amp;laquo; &lt;strong&gt;Send Shape&lt;/strong&gt; &amp;raquo; sur chaque branche de &amp;laquo; &lt;strong&gt;Decide Shape&lt;/strong&gt; &amp;raquo; et liez les aux Send Port que vous venez de cr&amp;eacute;er. 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; Au final votre orchestration devrait ressembler &amp;agrave; ceci : 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_24.png"&gt;&lt;img style="border: 0px" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CreruneorchestrationBizTalkavecVisualStu_3AFD/image_thumb_11.png" border="0" alt="image" width="244" height="159" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; Avant de pouvoir enfin d&amp;eacute;ployer, il faut sp&amp;eacute;cifier &amp;agrave; cette orchestration qu&amp;rsquo;elle peut-&amp;ecirc;tre automatiquement instanci&amp;eacute;e &amp;agrave; la r&amp;eacute;ception d&amp;rsquo;un Livre. 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; Ouvrez les propri&amp;eacute;t&amp;eacute;s du &amp;laquo; &lt;strong&gt;Receive Shape&lt;/strong&gt; &amp;raquo; et faites-y passer la propri&amp;eacute;t&amp;eacute; &amp;laquo; &lt;strong&gt;Activate&lt;/strong&gt; &amp;raquo; &amp;agrave; true. 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; &lt;strong&gt;Deployer&lt;/strong&gt; votre projet 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; Lier les ports logiques de cette orchestration avec des ports physique se fait dans &lt;strong&gt;BizTalk Server Administration&lt;/strong&gt;.
&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SimonBoigelotWorld/~4/335645894" height="1" width="1"/&gt;</description>
      <link>http://feeds.feedburner.com/~r/SimonBoigelotWorld/~3/335645894/post.aspx</link>
      <author>Togis</author>
      <comments>http://www.simonboigelot.com/post/Creacute;er-une-orchestration-BizTalk-avec-Visual-Studio.aspx#comment</comments>
      <guid isPermaLink="false">http://www.simonboigelot.com/post.aspx?id=e97a4a06-e3e6-4b71-85f2-75977fc71cc6</guid>
      <pubDate>Tue, 15 Jul 2008 04:12:00 +0200</pubDate>
      <category>BizTalk</category>
      <dc:publisher>Togis</dc:publisher>
      <pingback:server>http://www.simonboigelot.com/pingback.axd</pingback:server>
      <pingback:target>http://www.simonboigelot.com/post.aspx?id=e97a4a06-e3e6-4b71-85f2-75977fc71cc6</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://www.simonboigelot.com/trackback.axd?id=e97a4a06-e3e6-4b71-85f2-75977fc71cc6</trackback:ping>
      <wfw:comment>http://www.simonboigelot.com/post/Creacute;er-une-orchestration-BizTalk-avec-Visual-Studio.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.simonboigelot.com/syndication.axd?post=e97a4a06-e3e6-4b71-85f2-75977fc71cc6</wfw:commentRss>
    <feedburner:origLink>http://www.simonboigelot.com/post.aspx?id=e97a4a06-e3e6-4b71-85f2-75977fc71cc6</feedburner:origLink></item>
    <item>
      <title>Importer une application BizTalk &amp;agrave; partir d&amp;rsquo;un fichier MSI</title>
      <description>&lt;p&gt;
Suite de l&amp;#39;article : &lt;a href="http://www.simonboigelot.com/post/Exporter-une-application-BizTalk-agrave%3b-partir-drsquo%3bun-fichier-MSI.aspx"&gt;Exporter une application BizTalk &amp;agrave; partir d&amp;rsquo;un fichier MSI&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
Dans le but de cet exercice nous allons tout d&amp;rsquo;abord effacer toute trace de l&amp;rsquo;application SugarFactory de notre environnement BizTalk. 
&lt;/p&gt;
&lt;p&gt;
Pour ce faire : 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; Ouvrez BizTalk Server administration Console. 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; Stoppez l&amp;rsquo;application &amp;laquo; &lt;strong&gt;SugarFactory&lt;/strong&gt; &amp;raquo; 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/ImporteruneapplicationBizTalkpartirdunfi_3625/image_8.png"&gt;&lt;img style="border-width: 0px" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/ImporteruneapplicationBizTalkpartirdunfi_3625/image_thumb_3.png" border="0" alt="image" width="179" height="54" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; Une bo&amp;icirc;te de dialogue vous demande de choisir entre 3 diff&amp;eacute;rents arr&amp;ecirc;ts d&amp;rsquo;applications, choisissez &amp;laquo; &lt;strong&gt;Fill Stop &amp;ndash; Terminate instances&lt;/strong&gt; &amp;raquo; 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/ImporteruneapplicationBizTalkpartirdunfi_3625/image_6.png"&gt;&lt;img style="border-width: 0px" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/ImporteruneapplicationBizTalkpartirdunfi_3625/image_thumb_2.png" border="0" alt="image" width="244" height="89" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; Cliquez sur &lt;strong&gt;Stop&lt;/strong&gt;. 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; Cliquez avec le bouton droit de la souris sur votre application et s&amp;eacute;lectionnez &amp;laquo; &lt;strong&gt;Delete&lt;/strong&gt; &amp;raquo; 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; &amp;laquo; Do you wish to delete this application ? &amp;raquo; &amp;agrave; &lt;strong&gt;Yes&lt;/strong&gt; 
&lt;/p&gt;
&lt;p&gt;
Pour importer notre application SugarFactory &amp;agrave; partir du fichier MSI pr&amp;eacute;c&amp;eacute;demment cr&amp;eacute;e : 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; Ouvrez BizTalk Server administration Console. 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; Cliquez sur le n&amp;oelig;ud &amp;laquo; &lt;strong&gt;Application&lt;/strong&gt; &amp;raquo; avec le bouton droit de la souris et s&amp;eacute;lectionnez &amp;laquo; &lt;strong&gt;Import &lt;/strong&gt;&lt;strong&gt;&amp;agrave;&lt;/strong&gt;&lt;strong&gt; MSI File&lt;/strong&gt; &amp;raquo; 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/ImporteruneapplicationBizTalkpartirdunfi_3625/image_4.png"&gt;&lt;img style="border-width: 0px" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/ImporteruneapplicationBizTalkpartirdunfi_3625/image_thumb_1.png" border="0" alt="image" width="244" height="77" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; Dans la premi&amp;egrave;re page de l&amp;rsquo;assistant, s&amp;eacute;lectionnez le fichier MSI &amp;laquo; C:\TFE08BTS06\SugarFactory\Install\SugarFactory.msi &amp;raquo;&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; Cliquez deux foi sur &lt;strong&gt;Next&lt;/strong&gt; et ensuite sur &lt;strong&gt;Import&lt;/strong&gt;. 
&lt;/p&gt;
&lt;p&gt;
L&amp;rsquo;application SugarFactory est revenue dans l&amp;rsquo;environnement BizTalk, sans perdre aucune de ses configurations. 
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/ImporteruneapplicationBizTalkpartirdunfi_3625/image_2.png"&gt;&lt;img style="border-width: 0px" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/ImporteruneapplicationBizTalkpartirdunfi_3625/image_thumb.png" border="0" alt="image" width="244" height="103" /&gt;&lt;/a&gt;
&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SimonBoigelotWorld/~4/335645896" height="1" width="1"/&gt;</description>
      <link>http://feeds.feedburner.com/~r/SimonBoigelotWorld/~3/335645896/post.aspx</link>
      <author>Togis</author>
      <comments>http://www.simonboigelot.com/post/Importer-une-application-BizTalk-agrave;-partir-drsquo;un-fichier-MSI.aspx#comment</comments>
      <guid isPermaLink="false">http://www.simonboigelot.com/post.aspx?id=ddb9498e-8955-4fbe-b6e8-2d58a6a0159e</guid>
      <pubDate>Tue, 15 Jul 2008 03:52:00 +0200</pubDate>
      <category>BizTalk</category>
      <dc:publisher>Togis</dc:publisher>
      <pingback:server>http://www.simonboigelot.com/pingback.axd</pingback:server>
      <pingback:target>http://www.simonboigelot.com/post.aspx?id=ddb9498e-8955-4fbe-b6e8-2d58a6a0159e</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://www.simonboigelot.com/trackback.axd?id=ddb9498e-8955-4fbe-b6e8-2d58a6a0159e</trackback:ping>
      <wfw:comment>http://www.simonboigelot.com/post/Importer-une-application-BizTalk-agrave;-partir-drsquo;un-fichier-MSI.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.simonboigelot.com/syndication.axd?post=ddb9498e-8955-4fbe-b6e8-2d58a6a0159e</wfw:commentRss>
    <feedburner:origLink>http://www.simonboigelot.com/post.aspx?id=ddb9498e-8955-4fbe-b6e8-2d58a6a0159e</feedburner:origLink></item>
    <item>
      <title>Exporter une application BizTalk &amp;agrave; partir d&amp;rsquo;un fichier MSI</title>
      <description>&lt;p&gt;
Dans cet exercice nous allons apprendre &amp;agrave; exporter une application BizTalk &amp;agrave; partir de l&amp;rsquo;outil &amp;laquo; &lt;strong&gt;Export MSI wizard &lt;/strong&gt;&amp;raquo; de BizTalk 2006. 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; Ouvrez BizTalk Server administration Console. 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; Cliquez avec le bouton droit de la souris sur une de vos applications. Pourquoi pas &amp;laquo; &lt;strong&gt;SugarFactory&lt;/strong&gt; &amp;raquo;. S&amp;eacute;lectionnez &amp;laquo; &lt;strong&gt;Export &lt;/strong&gt;&lt;strong&gt;&amp;agrave;&lt;/strong&gt;&lt;strong&gt; MSI File&lt;/strong&gt; &amp;raquo; 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/ImporteruneapplicationBizTalkpartirdunfi_35A6/image_2.png"&gt;&lt;img style="border-width: 0px" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/ImporteruneapplicationBizTalkpartirdunfi_35A6/image_thumb.png" border="0" alt="image" width="240" height="114" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; Dans la page d&amp;rsquo;accueil de l&amp;rsquo;assistant, cliquez sur &lt;strong&gt;Next&lt;/strong&gt;. Et faite de m&amp;ecirc;me pour les pages suivantes jusqu&amp;rsquo;&amp;agrave; arriver &amp;agrave; la page &amp;laquo; &lt;strong&gt;Destination&lt;/strong&gt; &amp;raquo; 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; Changer la destination du fichier MSI g&amp;eacute;n&amp;eacute;r&amp;eacute; pour &amp;laquo; C:\TFE08BTS06\SugarFactory\Install\SugarFactory.msi &amp;raquo; 
&lt;/p&gt;
&lt;p&gt;
&amp;middot; Cliquez sur &lt;strong&gt;Export&lt;/strong&gt;
&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SimonBoigelotWorld/~4/335645898" height="1" width="1"/&gt;</description>
      <link>http://feeds.feedburner.com/~r/SimonBoigelotWorld/~3/335645898/post.aspx</link>
      <author>Togis</author>
      <comments>http://www.simonboigelot.com/post/Exporter-une-application-BizTalk-agrave;-partir-drsquo;un-fichier-MSI.aspx#comment</comments>
      <guid isPermaLink="false">http://www.simonboigelot.com/post.aspx?id=b64a9d5b-fc2b-4e24-bfd4-203e5ccb9489</guid>
      <pubDate>Tue, 15 Jul 2008 03:51:00 +0200</pubDate>
      <category>BizTalk</category>
      <dc:publisher>Togis</dc:publisher>
      <pingback:server>http://www.simonboigelot.com/pingback.axd</pingback:server>
      <pingback:target>http://www.simonboigelot.com/post.aspx?id=b64a9d5b-fc2b-4e24-bfd4-203e5ccb9489</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://www.simonboigelot.com/trackback.axd?id=b64a9d5b-fc2b-4e24-bfd4-203e5ccb9489</trackback:ping>
      <wfw:comment>http://www.simonboigelot.com/post/Exporter-une-application-BizTalk-agrave;-partir-drsquo;un-fichier-MSI.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.simonboigelot.com/syndication.axd?post=b64a9d5b-fc2b-4e24-bfd4-203e5ccb9489</wfw:commentRss>
    <feedburner:origLink>http://www.simonboigelot.com/post.aspx?id=b64a9d5b-fc2b-4e24-bfd4-203e5ccb9489</feedburner:origLink></item>
    <item>
      <title>Cr&amp;eacute;ation de sch&amp;eacute;ma avec l&amp;rsquo;&amp;eacute;diteur de BizTalk</title>
      <description>&lt;p&gt;Dans cet exercice, nous allons voir en détails comment créer un nouveau schéma en se passant de l’assistant (wizard) de Visual Studio.&lt;/p&gt; &lt;p&gt;· Ouvrez Visual Studio &lt;p&gt;· Créer un nouveau projet « &lt;b&gt;Empty Biztalk Server Project&lt;/b&gt; » du nom de « &lt;b&gt;LaboSchemas&lt;/b&gt; »&lt;br&gt;&lt;b&gt;&lt;/b&gt; &lt;p&gt;Prenez pour bonne habitude de directement changer le nom de déploiement du projet pour « &lt;b&gt;LaboSchemas&lt;/b&gt; ».&lt;br&gt;Pour rappel, changer le nom de déploiement d’un projet se fait dans les propriétés du projet, Onglet « &lt;b&gt;Configuration Properties &lt;/b&gt;&lt;b&gt;à Deployement&lt;/b&gt; », champ « &lt;b&gt;Application Name&lt;/b&gt; » &lt;p&gt;&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CrationdeschmaaveclditeurdeBizTalk_3F1F/image_2.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="158" alt="image" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CrationdeschmaaveclditeurdeBizTalk_3F1F/image_thumb.png" width="244" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Ainsi que de lui attribuer un clé de signature.&lt;/p&gt; &lt;p&gt;Pour rappel, cette clef se change dans les propriétés du projet, onglet « &lt;b&gt;Common Properties &lt;/b&gt;&lt;b&gt;à Assemly&lt;/b&gt; », champ « &lt;b&gt;Assembly Key File&lt;/b&gt; » &lt;p&gt;&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CrationdeschmaaveclditeurdeBizTalk_3F1F/image_4.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="158" alt="image" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CrationdeschmaaveclditeurdeBizTalk_3F1F/image_thumb_1.png" width="244" border="0"&gt;&lt;/a&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;· Dans l’explorateur de solution, cliquez avec le bouton droit de la souris sur votre projet et sélectionnez « &lt;b&gt;Add &lt;/b&gt;&lt;b&gt;à&lt;/b&gt;&lt;b&gt; New Item…&lt;/b&gt; » &lt;p&gt;· Dans la boîte de dialogue « &lt;b&gt;Add New Item&lt;/b&gt; », sous l’onglet « &lt;b&gt;Schema Files&lt;/b&gt; », choisissez le template « &lt;b&gt;Schema&lt;/b&gt; » et nommez le « &lt;b&gt;AdresseDeLivraison&lt;/b&gt; » &lt;p&gt;&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CrationdeschmaaveclditeurdeBizTalk_3F1F/image_6.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="150" alt="image" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CrationdeschmaaveclditeurdeBizTalk_3F1F/image_thumb_2.png" width="244" border="0"&gt;&lt;/a&gt;  &lt;p&gt;· Cliquez sur &lt;b&gt;Add&lt;/b&gt;. &lt;p&gt;· L’éditeur de schémas s’est maintenant ouvert dans Visual Studio, avec à gauche une représentation sous forme de TreeView, et à droite le code XSD de notre schéma. &lt;p&gt;· Dans le TreeView, cliquez sur « &lt;b&gt;Root&lt;/b&gt; » avec le bouton droit de la souris et renommez le « &lt;b&gt;AdresseDeLivraison&lt;/b&gt; » &lt;p&gt;&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CrationdeschmaaveclditeurdeBizTalk_3F1F/image_8.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="160" alt="image" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CrationdeschmaaveclditeurdeBizTalk_3F1F/image_thumb_3.png" width="244" border="0"&gt;&lt;/a&gt;  &lt;p&gt;· Cliquez avec le bouton droit de la souris sur le nœud « &lt;b&gt;adresseDeLivraison&lt;/b&gt; » et sélectionnez « &lt;b&gt;Insert Schema Node &lt;/b&gt;&lt;b&gt;à&lt;/b&gt;&lt;b&gt; Child Field Element&lt;/b&gt; », nommez cet élément « &lt;b&gt;Ville&lt;/b&gt; ».&lt;b&gt;&lt;br&gt;&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CrationdeschmaaveclditeurdeBizTalk_3F1F/image_10.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="119" alt="image" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CrationdeschmaaveclditeurdeBizTalk_3F1F/image_thumb_4.png" width="244" border="0"&gt;&lt;/a&gt; &lt;/b&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CrationdeschmaaveclditeurdeBizTalk_3F1F/image_12.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="90" alt="image" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CrationdeschmaaveclditeurdeBizTalk_3F1F/image_thumb_5.png" width="236" border="0"&gt;&lt;/a&gt;&amp;nbsp;&lt;b&gt;&lt;/p&gt;&lt;/b&gt; &lt;p&gt;· Recommencez l’étape précédente pour les champs suivant : &lt;blockquote&gt; &lt;p&gt;o Pays&lt;br&gt;o Rue&lt;br&gt;o Emai&lt;br&gt;o Fax&lt;br&gt;o Localité&lt;br&gt;o CodePostal&lt;br&gt;o Téléphone&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;· Enregistrez votre schéma. &lt;p&gt;Comme nous pouvons le remarquer sur cette image : &lt;p&gt;&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CrationdeschmaaveclditeurdeBizTalk_3F1F/image_14.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="220" alt="image" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CrationdeschmaaveclditeurdeBizTalk_3F1F/image_thumb_6.png" width="244" border="0"&gt;&lt;/a&gt;  &lt;p&gt;Il existe différent type d’élément de schéma. Les plus intéressants étant les suivant : &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;table cellspacing="0" cellpadding="2" width="400" border="1"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td valign="top" width="200"&gt;&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CrationdeschmaaveclditeurdeBizTalk_3F1F/image_18.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="36" alt="image" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CrationdeschmaaveclditeurdeBizTalk_3F1F/image_thumb_8.png" width="132" border="0"&gt;&lt;/a&gt; &lt;/td&gt; &lt;td valign="top" width="200"&gt; &lt;p&gt;Un child record est un enfant polymorphe qui peut contenir tout et n’importe quoi. C’est l’élément le plus simple qui existe.&lt;br&gt;En XML, il se présentera sous forme d’un élément enfant :&lt;br&gt;&amp;lt;NoeudRoot&amp;gt;&amp;lt;Enfant/&amp;gt;&amp;lt;/NoeudRoot&amp;gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="200"&gt;&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CrationdeschmaaveclditeurdeBizTalk_3F1F/image_20.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="28" alt="image" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CrationdeschmaaveclditeurdeBizTalk_3F1F/image_thumb_9.png" width="138" border="0"&gt;&lt;/a&gt; &lt;/td&gt; &lt;td valign="top" width="200"&gt; &lt;p&gt;Le field attribute est l’équivalent du child record hors mit qu’en XML il se représentera sous forme d’un attribut : &lt;p&gt;&amp;lt;NoeudRoot Attribut= « »/&amp;gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="200"&gt;&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CrationdeschmaaveclditeurdeBizTalk_3F1F/image_22.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="35" alt="image" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CrationdeschmaaveclditeurdeBizTalk_3F1F/image_thumb_10.png" width="158" border="0"&gt;&lt;/a&gt; &lt;/td&gt; &lt;td valign="top" width="200"&gt; &lt;p&gt;Similaire au child Record en ce qui nous concerne excepté que celui-ci ne peut pas contenir d’enfant.&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="200"&gt;&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CrationdeschmaaveclditeurdeBizTalk_3F1F/image_24.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="29" alt="image" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CrationdeschmaaveclditeurdeBizTalk_3F1F/image_thumb_11.png" width="129" border="0"&gt;&lt;/a&gt; &lt;/td&gt; &lt;td valign="top" width="200"&gt; &lt;p&gt;L’élément sequence group permet de définir des séquence tel que celle-ci : &lt;p&gt;&amp;lt;Livres&amp;gt;&lt;br&gt;&amp;nbsp; &amp;lt;Livre/&amp;gt;&lt;br&gt;&amp;nbsp; &amp;lt;Livre/&amp;gt;&lt;br&gt;&amp;nbsp; &amp;lt;Livre/&amp;gt;&lt;br&gt;&amp;lt;/Livres&amp;gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p&gt;Différentes contraintes sont applicables à ces éléments. Vous en trouverez une liste en cliquant sur l’élément « &lt;b&gt;Ville&lt;/b&gt; » de notre précédent schéma, dans le panel des propriétés de l’élément.&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CrationdeschmaaveclditeurdeBizTalk_3F1F/image_16.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="244" alt="image" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/CrationdeschmaaveclditeurdeBizTalk_3F1F/image_thumb_7.png" width="208" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Ces contraintes, une foi intégrées au schéma, seront vérifiées par BizTalk à chaque étape d’un processus métier. Si l’une d’elle n’est pas respectée, le message sera mit en attente d’une action d’un administrateur, pour peu que l’erreur généré ne soit pas gérée dans le code du processus.&lt;img src="http://feeds.feedburner.com/~r/SimonBoigelotWorld/~4/335667294" height="1" width="1"/&gt;</description>
      <link>http://feeds.feedburner.com/~r/SimonBoigelotWorld/~3/335667294/post.aspx</link>
      <author>Togis</author>
      <comments>http://www.simonboigelot.com/post/Creacute;ation-de-scheacute;ma-avec-lrsquo;eacute;diteur-de-BizTalk.aspx#comment</comments>
      <guid isPermaLink="false">http://www.simonboigelot.com/post.aspx?id=82eba55e-ad9d-414d-b11d-054de72a085e</guid>
      <pubDate>Tue, 15 Jul 2008 02:28:50 +0200</pubDate>
      <category>BizTalk</category>
      <dc:publisher>Togis</dc:publisher>
      <pingback:server>http://www.simonboigelot.com/pingback.axd</pingback:server>
      <pingback:target>http://www.simonboigelot.com/post.aspx?id=82eba55e-ad9d-414d-b11d-054de72a085e</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://www.simonboigelot.com/trackback.axd?id=82eba55e-ad9d-414d-b11d-054de72a085e</trackback:ping>
      <wfw:comment>http://www.simonboigelot.com/post/Creacute;ation-de-scheacute;ma-avec-lrsquo;eacute;diteur-de-BizTalk.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.simonboigelot.com/syndication.axd?post=82eba55e-ad9d-414d-b11d-054de72a085e</wfw:commentRss>
    <feedburner:origLink>http://www.simonboigelot.com/post.aspx?id=82eba55e-ad9d-414d-b11d-054de72a085e</feedburner:origLink></item>
    <item>
      <title>Threading et Mutex - AutoResetEvent - ReaderWriterLock</title>
      <description>&lt;p&gt;Ca y est, la mode est lancée, on n'entend plus parler que de programmation asynchrone, parrallèlle, etc. Tout ça en prévision d'un futur, pas si lointain que ça, où nous n'aurons plus assé de doigts pour compter le nombre de core processeur notre pc contient.&lt;/p&gt; &lt;p&gt;Le multithreadé est l'avenir, et bien que l'on espère voir apparaître un jour un super framework qui gérera tout ça pour nous en attendant il faut bien ressortir nos vieux bouquins et se demander : "mais, et si je devais programmer du multithreadé maintenant, et si je voulais le faire bien pour une foi, quel patern devrais-je appliquer?"&lt;/p&gt; &lt;p&gt;Et bien, rien de plus simple ;) (Ca fait peur quand ça commence comme ça non?)&lt;/p&gt; &lt;p&gt;Tout d'abord, revoyons rapidement deux bases : les mutex et les events.&lt;/p&gt; &lt;h2&gt;&lt;/h2&gt; &lt;h2&gt;Mutex&lt;/h2&gt; &lt;p&gt;Le mutex est un des moyens les plus bas niveau pour proteger l'acces concurent à une ressource partagée.&lt;/p&gt; &lt;p&gt;On peut voir un mutex comme une clefs unique pour un verou unique. Si je prend la clefs, mon voisin ne saura pas la prendre tant que je ne l'aurais pas remise sur la table, et donc va attendre que je la repose avant de continuer.&lt;/p&gt; &lt;p&gt;En C# la class Mutex contient 2 methodes indispensable :&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;strong&gt;WaitOne()&lt;/strong&gt; : (ou "Prendre la clefs") Vérifie qu'aucun autre thread n'a la main sur le Mutex, dans le cas contraire, bloque le thread appellant jusqu'à la libération du Mutex par celui qui le possède.  &lt;li&gt;&lt;strong&gt;ReleaseMutex()&lt;/strong&gt; : (ou "Rendre la clefs") Libère le Mutex.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/ThreadingetMutexAutoResetEventReaderWrit_EFFA/image_2.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="404" alt="image" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/ThreadingetMutexAutoResetEventReaderWrit_EFFA/image_thumb.png" width="304" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Voici un exemple de code pour illustrer les Mutex, dans ce cas-ci aucune ressource n'est protégée, mais le principe est le même, la ressource protégée doit être accédée uniquement quand le thread courant possède le Mutex. (Dans le cas d'un Mutex, si l'on ne joue pas le jeu, le système ne criera pas sur vous).&lt;/p&gt; &lt;p&gt;&lt;div class="code"&gt;
[code:c#]&lt;br&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Threading; &lt;/p&gt; &lt;p&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; Blog&lt;br&gt;{&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;class&lt;/span&gt; Program&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; ThreadWriteLine(&lt;span class="kwrd"&gt;string&lt;/span&gt; s)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine(Thread.CurrentThread.ManagedThreadId + &lt;span class="str"&gt;" &amp;gt; "&lt;/span&gt; + s);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; TimerCallback(&lt;span class="kwrd"&gt;object&lt;/span&gt; MutexHandle)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ThreadWriteLine(&lt;span class="str"&gt;"Waiting mutex"&lt;/span&gt;);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (MutexHandle &lt;span class="kwrd"&gt;as&lt;/span&gt; Mutex).WaitOne();&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ThreadWriteLine(&lt;span class="str"&gt;"I have the mutex ! --&amp;gt; sleep"&lt;/span&gt;);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Thread.Sleep(5000);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ThreadWriteLine(&lt;span class="str"&gt;"Releasing mutex"&lt;/span&gt;);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (MutexHandle &lt;span class="kwrd"&gt;as&lt;/span&gt; Mutex).ReleaseMutex();&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Main(&lt;span class="kwrd"&gt;string&lt;/span&gt;[] args)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Program p = &lt;span class="kwrd"&gt;new&lt;/span&gt; Program();&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Mutex MutexHandle = &lt;span class="kwrd"&gt;new&lt;/span&gt; Mutex(&lt;span class="kwrd"&gt;false&lt;/span&gt;);  &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; i = 0; i &amp;lt; 5; i++)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Timer T = &lt;span class="kwrd"&gt;new&lt;/span&gt; Timer(&lt;span class="kwrd"&gt;new&lt;/span&gt; TimerCallback(p.TimerCallback), MutexHandle, 0, 0);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.ReadKey();&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;}&lt;br&gt;[/code]&lt;/div&gt;  &lt;p&gt;&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/ThreadingetMutexAutoResetEventReaderWrit_EFFA/image_8.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="125" alt="image" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/ThreadingetMutexAutoResetEventReaderWrit_EFFA/image_thumb_3.png" width="244" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;h2&gt;AutoResetEvent&lt;/h2&gt; &lt;p&gt;Les évents, ou plustôt les AutoResetEvents vont nous permettre d'envoyer un signal d'un thread à un autre.&lt;/p&gt; &lt;p&gt;Cette Class contient elle aussi deux méthodes :&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;strong&gt;WaitOne()&lt;/strong&gt; : met le thread courent en attente jusqu'à ce qu'un autre emette un évènement sur ce même AutoResetEvent&lt;/li&gt; &lt;li&gt;&lt;strong&gt;Set()&lt;/strong&gt; : emet un évènement sur un AutoResetEvent&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/ThreadingetMutexAutoResetEventReaderWrit_EFFA/image4.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="412" alt="image" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/ThreadingetMutexAutoResetEventReaderWrit_EFFA/image4_thumb.png" width="304" border="0"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Une foi de plus, voici un petit bout de code pour illustrer l'utilisation des AutoResetEvent :&lt;/p&gt; &lt;p&gt;&lt;div class="code"&gt;
[code:c#]&lt;br&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; Blog&lt;br&gt;{&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;class&lt;/span&gt; Program&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; TimerCallback(Object waitHandle)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ThreadWriteLine(&lt;span class="str"&gt;"TimeCallBack Begin"&lt;/span&gt;);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Thread.Sleep(1000);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (waitHandle &lt;span class="kwrd"&gt;as&lt;/span&gt; AutoResetEvent).Set();&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;/p&gt; &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Main(&lt;span class="kwrd"&gt;string&lt;/span&gt;[] args)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Program p = &lt;span class="kwrd"&gt;new&lt;/span&gt; Program();&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AutoResetEvent waitHandle = &lt;span class="kwrd"&gt;new&lt;/span&gt; AutoResetEvent(&lt;span class="kwrd"&gt;false&lt;/span&gt;);  &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Timer T = &lt;span class="kwrd"&gt;new&lt;/span&gt; Timer(&lt;span class="kwrd"&gt;new&lt;/span&gt; TimerCallback(p.TimerCallback), waitHandle, 0, 0);  &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; waitHandle.WaitOne();  &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; p.ThreadWriteLine(&lt;span class="str"&gt;"Event Fired"&lt;/span&gt;);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine(&lt;span class="str"&gt;"Press a key"&lt;/span&gt;);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.ReadKey();&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; ThreadWriteLine(&lt;span class="kwrd"&gt;string&lt;/span&gt; s)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine(Thread.CurrentThread.ManagedThreadId + &lt;span class="str"&gt;" &amp;gt; "&lt;/span&gt; + s);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;}&lt;br&gt;[/code]&lt;/div&gt; &lt;p&gt;&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/ThreadingetMutexAutoResetEventReaderWrit_EFFA/image_9.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="125" alt="image" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/ThreadingetMutexAutoResetEventReaderWrit_EFFA/image_thumb_1.png" width="244" border="0"&gt;&lt;/a&gt;  &lt;h2&gt;ReaderWriterLock&lt;/h2&gt; &lt;p&gt;Nous avons vu qu'un Mutex pouvait protéger une ressource,mais avouons que c'est une méthode très bas niveau. Le framework .Net nous offre des class toute faites, prévue pour chaque situation, tel que celle-ci, le ReaderWriterLock.&lt;/p&gt; &lt;p&gt;Le ReaderWriterLock est une class qui permet de limiter l'acces à une ressource, de manière unitaire en écriture mais de manière concurente en lecture.&lt;/p&gt; &lt;p&gt;Soit :&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Si deux threads essayent d'écrire dans la ressource simultanément, l'un des deux va devoir attendre la fin du travail du suivant&lt;/li&gt; &lt;li&gt;Si deux threads essayent de lire la ressource et qu'aucun autre thread n'est en train d'y écrire, il vont pouvoir le faire simultanément&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Nous alos donc, cette foi, avoir 4 méthodes au lieu de 2 :&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;strong&gt;AcquireWriterLock()&lt;/strong&gt; : demande de permission d'écrirure, si un autre thread à déjà cette permission, cette méthode est bloquante&lt;/li&gt; &lt;li&gt;&lt;strong&gt;ReleaseWriterLock()&lt;/strong&gt; : libère la permission d'écriture&lt;/li&gt; &lt;li&gt;&lt;strong&gt;AcquireReaderLock()&lt;/strong&gt; : demande de permission de lecture, su un autre thread possède la permission d'écrire, cette méthode est bloquante&lt;/li&gt; &lt;li&gt;&lt;strong&gt;ReleaseReaderLock()&lt;/strong&gt; : libère la permission de lecture&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/ThreadingetMutexAutoResetEventReaderWrit_EFFA/image1.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="299" alt="image" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/ThreadingetMutexAutoResetEventReaderWrit_EFFA/image1_thumb.png" width="554" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Dans l'exemple qui suit, un thread writer crée un thread enfant demandant une permission de lecture, on constate que cette permission ne lui est accordée que quand le thread writer à effectué son ReleaseWriterLock(). &lt;/p&gt; &lt;p&gt;&lt;div class="code"&gt;
[code:c#]&lt;br&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System;&lt;br&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Threading; &lt;/p&gt; &lt;p&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; ConsoleApplication9&lt;br&gt;{&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;class&lt;/span&gt; Program&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;private&lt;/span&gt; ReaderWriterLock LockHandle;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; val;  &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;public&lt;/span&gt; Program()&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LockHandle = &lt;span class="kwrd"&gt;new&lt;/span&gt; ReaderWriterLock();&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; val = &lt;span class="str"&gt;""&lt;/span&gt;;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; ThreadWriteLine(&lt;span class="kwrd"&gt;string&lt;/span&gt; s)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine(Thread.CurrentThread.ManagedThreadId + &lt;span class="str"&gt;" &amp;gt; "&lt;/span&gt; + s);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Read()&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LockHandle.AcquireReaderLock(Timeout.Infinite);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ThreadWriteLine(&lt;span class="str"&gt;"AcquireReaderLock &amp;gt; val :'"&lt;/span&gt; + val + &lt;span class="str"&gt;"'"&lt;/span&gt;);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Thread.Sleep(1000);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ThreadWriteLine(&lt;span class="str"&gt;"ReleaseReaderLock &amp;gt; val :'"&lt;/span&gt; + val + &lt;span class="str"&gt;"'"&lt;/span&gt;);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LockHandle.ReleaseReaderLock();&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Write() &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LockHandle.AcquireWriterLock(Timeout.Infinite);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ThreadWriteLine(&lt;span class="str"&gt;"AcquireWriterLock! &amp;gt; writing start"&lt;/span&gt;);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;int&lt;/span&gt; id = LockHandle.WriterSeqNum;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ThreadWriteLine(&lt;span class="str"&gt;"WriterSeqNum = "&lt;/span&gt; + id); &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Thread.Sleep(1000); &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; val = &lt;span class="str"&gt;"Hello "&lt;/span&gt;; &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Thread.Sleep(1000);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (&lt;span class="kwrd"&gt;new&lt;/span&gt; Thread(&lt;span class="kwrd"&gt;new&lt;/span&gt; ThreadStart(&lt;span class="kwrd"&gt;this&lt;/span&gt;.Read))).Start();&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; val += &lt;span class="str"&gt;"World "&lt;/span&gt;; &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Thread.Sleep(1000); &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; val += &lt;span class="str"&gt;"I'm "&lt;/span&gt;; &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Thread.Sleep(1000); &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; val += &lt;span class="str"&gt;"a writer !"&lt;/span&gt;; &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Thread.Sleep(1000);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ThreadWriteLine(&lt;span class="str"&gt;"ReleaseWriterLock"&lt;/span&gt;);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LockHandle.ReleaseWriterLock(); &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Main(&lt;span class="kwrd"&gt;string&lt;/span&gt;[] args)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Program p = &lt;span class="kwrd"&gt;new&lt;/span&gt; Program(); &lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Thread[] writer = &lt;span class="kwrd"&gt;new&lt;/span&gt; Thread[10]; &lt;/p&gt; &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; i = 0; i &amp;lt; 3; i++)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; writer[i] = &lt;span class="kwrd"&gt;new&lt;/span&gt; Thread(&lt;span class="kwrd"&gt;new&lt;/span&gt; ThreadStart(p.Write));&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; i = 0; i &amp;lt; 3; i++)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; writer[i].Start();&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.ReadKey();&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;}&lt;br&gt;[/code]&lt;/div&gt;&lt;br&gt;&lt;em&gt;NB : Ceci n'est qu'un exemple, généralement, éviter d'utiliser ThreadStart, choisisez de préférence l'utilisation du pool de thread de l'application.&lt;/em&gt; &lt;p&gt;&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/ThreadingetMutexAutoResetEventReaderWrit_EFFA/image_11.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="125" alt="image" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/ThreadingetMutexAutoResetEventReaderWrit_EFFA/image_thumb_4.png" width="244" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;h2&gt;Conclusion&lt;/h2&gt; &lt;p&gt;Il existe déjà dans le monde .Net de nombreux moyens pour synchroniser différents threads lorsque néccessaire. De nombreuses règles de bonnes pratique existe et nous évite de nous arracher les cheveux.&lt;/p&gt; &lt;p&gt;Ce que l'avenir nous réserve dans tout ça ? Avec la mutiplication des traîtements parrallèle, l'écriture "humaine" d'une gestion de ces traîtements sera rapidement longue, fastidieuse, voir impossible. Nous allons voir apparaître de nouveaux languages (tel que le F#) ainsi que des librairies pour les languages existants (tel que Microsoft.Research.Join) nous permettant une programmation plus déclarative que celle à laquelle nous sommes habitué.&lt;/p&gt; &lt;p&gt;Mais je pense qu'il ne faut pas négliger les bases, ces concepts, même s'ils deviendront peut-être invisibles, seront de plus en plus existant au sein même de nos applications.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SimonBoigelotWorld/~4/182230360" height="1" width="1"/&gt;</description>
      <link>http://feeds.feedburner.com/~r/SimonBoigelotWorld/~3/182230360/post.aspx</link>
      <author>Togis</author>
      <comments>http://www.simonboigelot.com/post/Threading-et-Mutex---AutoResetEvent---ReaderWriterLock.aspx#comment</comments>
      <guid isPermaLink="false">http://www.simonboigelot.com/post.aspx?id=cda21d41-252c-4d8b-b8c6-216016b4bf3f</guid>
      <pubDate>Fri, 09 Nov 2007 15:48:44 +0200</pubDate>
      <category>General</category>
      <dc:publisher>Togis</dc:publisher>
      <pingback:server>http://www.simonboigelot.com/pingback.axd</pingback:server>
      <pingback:target>http://www.simonboigelot.com/post.aspx?id=cda21d41-252c-4d8b-b8c6-216016b4bf3f</pingback:target>
      <slash:comments>1</slash:comments>
      <trackback:ping>http://www.simonboigelot.com/trackback.axd?id=cda21d41-252c-4d8b-b8c6-216016b4bf3f</trackback:ping>
      <wfw:comment>http://www.simonboigelot.com/post/Threading-et-Mutex---AutoResetEvent---ReaderWriterLock.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.simonboigelot.com/syndication.axd?post=cda21d41-252c-4d8b-b8c6-216016b4bf3f</wfw:commentRss>
    <feedburner:origLink>http://www.simonboigelot.com/post.aspx?id=cda21d41-252c-4d8b-b8c6-216016b4bf3f</feedburner:origLink></item>
    <item>
      <title>WPF - Binding List to UI - Un petit r&amp;eacute;sum&amp;eacute; rapide mais utile</title>
      <description>&lt;p&gt;
Nous pouvons voir partout de nombreux exemples expliquant comment binder une liste d&amp;#39;&amp;eacute;l&amp;eacute;ments vers une interface xaml de notre application, voici en passant, un r&amp;eacute;sum&amp;eacute; reprennant les diff&amp;eacute;rentes &amp;eacute;tapes pour mettre en place ce genre de binding. 
&lt;/p&gt;
&lt;h2&gt;Que Binder ?&lt;/h2&gt;
&lt;p&gt;
Techniquement, vous pouvez binder n&amp;#39;importe quelle type de liste, que ce soit une List&amp;lt;Generique&amp;gt;, un tableau, une ArrayList, tout passera, cependant, vous vous rendrez vitte compte que seul les &lt;strong&gt;ObservableCollection&amp;lt;&amp;gt;&lt;/strong&gt; offrent un support pr&amp;eacute;-int&amp;eacute;gr&amp;eacute; pour l&amp;#39;update du binding lors de l&amp;#39;ajout ou du retrait d&amp;#39;un &amp;eacute;l&amp;eacute;ment de la collection. 
&lt;/p&gt;
&lt;p&gt;
Donc, &amp;agrave; mon avis, quitte &amp;agrave; avoir parfois besoin d&amp;#39;ObservableCollection, hors mit autre contrainte, autant toujours les utiliser. 
&lt;/p&gt;
&lt;h2&gt;Ou binder ?&lt;/h2&gt;
&lt;p&gt;
La class &lt;strong&gt;ItemsControl&lt;/strong&gt; est la class de base des conteneur de list de n&amp;#39;importe d&amp;#39;item. De cette class d&amp;eacute;rive tout ce qui est Menu, ListBox, ComboBox, TreeView, ...&lt;br /&gt;
Tout ce qui est customisable sur un&amp;nbsp; ItemControl est donc aussi customisable sur un de ses d&amp;eacute;riv&amp;eacute;. 
&lt;/p&gt;
&lt;p&gt;
Binder une liste se fait des deux cot&amp;eacute; de notre interface, premi&amp;egrave;rement dans les d&amp;eacute;claration xaml, ensuite dans le code behind. 
&lt;/p&gt;
&lt;p&gt;
Prennon un exemple simple, une liste d&amp;#39;employ&amp;eacute;s : 
&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;&lt;strong&gt;Creation de notre class d&amp;#39;exemple&lt;/strong&gt;&lt;br /&gt;
	&lt;div class="code"&gt;
[code:c#]&lt;br /&gt;
    &lt;span class="kwrd"&gt;class&lt;/span&gt; Employee&lt;br /&gt;
    {&lt;br /&gt;
    &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; _nom;&lt;br /&gt;
    &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Nom&lt;br /&gt;
    &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
    &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; get { &lt;span class="kwrd"&gt;return&lt;/span&gt; _nom; }&lt;br /&gt;
    &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set { _nom = &lt;span class="kwrd"&gt;value&lt;/span&gt;; }&lt;br /&gt;
    &amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;br /&gt;
    &lt;br /&gt;
    &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; _prenom;&lt;br /&gt;
    &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Prenom&lt;br /&gt;
    &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
    &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; get { &lt;span class="kwrd"&gt;return&lt;/span&gt; _prenom; }&lt;br /&gt;
    &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set { _prenom = &lt;span class="kwrd"&gt;value&lt;/span&gt;; }&lt;br /&gt;
    &amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;br /&gt;
    &lt;br /&gt;
    &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; _age;&lt;br /&gt;
    &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; Age&lt;br /&gt;
    &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
    &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; get { &lt;span class="kwrd"&gt;return&lt;/span&gt; _age; }&lt;br /&gt;
    &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set { _age = &lt;span class="kwrd"&gt;value&lt;/span&gt;; }&lt;br /&gt;
    &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
    }&lt;br /&gt;
    [/code]&lt;/div&gt;&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;Cr&amp;eacute;ation de notre ObservableCollection dans le code behind de notre application&lt;/strong&gt;&lt;br /&gt;
	&lt;div class="code"&gt;
[code:c#]&lt;br /&gt;
    &lt;span class="kwrd"&gt;public&lt;/span&gt; Window1()&lt;br /&gt;
    {&lt;br /&gt;
    &amp;nbsp;&amp;nbsp;&amp;nbsp; InitializeComponent(); &lt;/li&gt;
    &lt;p&gt;
    &amp;nbsp;&amp;nbsp;&amp;nbsp; ObservableCollection&amp;lt;Employee&amp;gt; list = &lt;span class="kwrd"&gt;new&lt;/span&gt; ObservableCollection&amp;lt;Employee&amp;gt;()&lt;br /&gt;
    &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
    &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;new&lt;/span&gt; Employee() { Prenom = &amp;quot;Simon&amp;quot;, Nom = &amp;quot;Boigelot&amp;quot;, Age=22 },&lt;br /&gt;
    &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;new&lt;/span&gt; Employee() { Prenom = &amp;quot;Lo&amp;iuml;c&amp;quot;, Nom = &amp;quot;Bar&amp;quot;, Age=19 },&lt;br /&gt;
    &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;new&lt;/span&gt; Employee() { Prenom = &amp;quot;Thieu&amp;quot;, Nom = &amp;quot;Lizin&amp;quot;, Age=21 }&lt;br /&gt;
    &amp;nbsp;&amp;nbsp;&amp;nbsp; };&lt;br /&gt;
    }&lt;br /&gt;
    [/code]&lt;/div&gt; 
	&lt;/p&gt;
	&lt;li&gt;&lt;strong&gt;Creation de notre ItemControl dans les d&amp;eacute;claration xaml&lt;br /&gt;
	&lt;/strong&gt;&lt;div class="code"&gt;
[code:xml]&lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Window&lt;/span&gt; &lt;span class="attr"&gt;x:Class&lt;/span&gt;&lt;span class="kwrd"&gt;="SimpleBinding.Window1"&lt;/span&gt;&lt;br /&gt;        &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt;&lt;br /&gt;        &lt;span class="attr"&gt;xmlns:x&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt;&lt;br /&gt;        &lt;span class="attr"&gt;Title&lt;/span&gt;&lt;span class="kwrd"&gt;="Window1"&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="300"&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="300"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;br /&gt;    &lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ItemsControl&lt;/span&gt; &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;="myItemControl"&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt; &lt;br /&gt;    &lt;br /&gt;    &lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Window&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    [/code]&lt;/div&gt; 
	&lt;/p&gt;
&lt;/ol&gt;
&lt;p&gt;
Nous avons maintenant une liste, un endroit ou l&amp;#39;afficher, mais il manque encore un lien entre les deux. 
&lt;/p&gt;
&lt;p&gt;
Ce lien se fait &amp;agrave; partir de la propri&amp;eacute;t&amp;eacute; ItemSource de notre ItemsControl. 
&lt;/p&gt;
&lt;h3&gt;D&amp;eacute;finir l&amp;#39;ItemSource dans le code behind&lt;/h3&gt;
&lt;p&gt;
Par exemple, nous pouvons simplement lier notre liste &amp;agrave; notre ItemsControl dans le code behind :&lt;br /&gt;
&lt;div class="code"&gt;
[code:c#]&lt;br /&gt;
myItemControl.ItemsSource = list;&lt;br /&gt;
[/code]&lt;/div&gt; 
&lt;/p&gt;
&lt;p&gt;
Le r&amp;eacute;sultat sera directement visible :&lt;br /&gt;
&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/WPFBindingListtoUIUnpetitrsumrapidemaisu_C14C/image_2.png"&gt;&lt;img style="border: 0px" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/WPFBindingListtoUIUnpetitrsumrapidemaisu_C14C/image_thumb.png" border="0" alt="image" width="244" height="242" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;h3&gt;D&amp;eacute;finir l&amp;#39;ItemSource dans les d&amp;eacute;finition xaml&lt;/h3&gt;
&lt;p&gt;
Malheureusement, bien que la solution pr&amp;eacute;c&amp;eacute;dente pour lier notre list &amp;agrave; l&amp;#39;interface semble fonctionner, ce n&amp;#39;est pas celle qui sera retenue car elle ne respecte pas du tout la s&amp;eacute;paration entre le code et l&amp;#39;interface. 
&lt;/p&gt;
&lt;p&gt;
Imaginons, par exemple, vouloir retrouver cette liste &amp;agrave; deux endroits diff&amp;eacute;rents de l&amp;#39;interface, dans ce dernier cas, il faudrait revenir dans le code behind et ajouter une ligne, ect. 
&lt;/p&gt;
&lt;p&gt;
La meilleur m&amp;eacute;thode pour binder une liste &amp;agrave; une interface est de passer par un ObjectDataProvider : 
&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;&lt;strong&gt;Changer notre xaml pour y int&amp;eacute;grer notre ObjectDateProvider&lt;/strong&gt;&lt;br /&gt;
	&lt;div class="code"&gt;
[code:xml]&lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Window&lt;/span&gt; &lt;span class="attr"&gt;x:Class&lt;/span&gt;&lt;span class="kwrd"&gt;="SimpleBinding.Window1"&lt;/span&gt;&lt;br /&gt;        &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt;&lt;br /&gt;        &lt;span class="attr"&gt;xmlns:x&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt;&lt;br /&gt;        &lt;span class="attr"&gt;Title&lt;/span&gt;&lt;span class="kwrd"&gt;="Window1"&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="300"&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="300"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Window.Resources&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ObjectDataProvider&lt;/span&gt; &lt;span class="attr"&gt;x:Key&lt;/span&gt;&lt;span class="kwrd"&gt;="myEmployeeList"&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Window.Resources&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ItemsControl&lt;/span&gt; &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;="myItemControl"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ItemsControl.ItemsSource&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Binding&lt;/span&gt; &lt;span class="attr"&gt;Source&lt;/span&gt;&lt;span class="kwrd"&gt;="{StaticResource myEmployeeList}"&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;                &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ItemsControl.ItemsSource&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ItemsControl&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Window&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    [/code]&lt;/div&gt;&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;Changer notre code behind pour lier notre list &amp;agrave; notre ObjectDataProvider&lt;br /&gt;
	&lt;/strong&gt;&lt;div class="code"&gt;
[code:c#]&lt;br /&gt;
    &lt;span class="kwrd"&gt;public&lt;/span&gt; Window1()&lt;br /&gt;
    {&lt;br /&gt;
    &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="rem"&gt;//init + create list&lt;br /&gt;&lt;/span&gt;
    &lt;br /&gt;
    &amp;nbsp;&amp;nbsp;&amp;nbsp; ObjectDataProvider odp = &lt;span class="kwrd"&gt;this&lt;/span&gt;.FindResource(&amp;quot;myEmployeeList&amp;quot;) &lt;span class="kwrd"&gt;as&lt;/span&gt; ObjectDataProvider;&lt;br /&gt;
    &amp;nbsp;&amp;nbsp;&amp;nbsp; odp.ObjectInstance = list;&lt;br /&gt;
    }&lt;br /&gt;
    [/code]&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
Le r&amp;eacute;sultat est exactement le m&amp;ecirc;me que dans le dernier exemple, mais nous passons par un interm&amp;eacute;diaire suppl&amp;eacute;m&amp;eacute;ntaire qui assure la s&amp;eacute;paration du code. 
&lt;/p&gt;
&lt;h2&gt;Comment rendre le tout lisible ?&lt;/h2&gt;
&lt;p&gt;
Par defaut, le binding utilise la m&amp;eacute;thode ToString() des objects que vous lui donner. 
&lt;/p&gt;
&lt;h3&gt;ToString()&lt;/h3&gt;
&lt;p&gt;
Une premi&amp;egrave;re m&amp;eacute;thode pour rendre votre binding lisible est donc simplement d&amp;#39;overrider cette m&amp;eacute;thode :&lt;br /&gt;
&lt;div class="code"&gt;
[code:c#]&lt;br /&gt;
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Employee&lt;br /&gt;
{ 
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="rem"&gt;//properties...&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; ToString()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;return&lt;/span&gt; Nom + &amp;quot; &amp;quot; + Prenom + &amp;quot; (&amp;quot; + Age + &amp;quot;)&amp;quot;;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
}&lt;br /&gt;
[/code]&lt;/div&gt; 
&lt;/p&gt;
&lt;p&gt;
R&amp;eacute;sultat:&lt;br /&gt;
&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/WPFBindingListtoUIUnpetitrsumrapidemaisu_C14C/image_4.png"&gt;&lt;img style="border: 0px" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/WPFBindingListtoUIUnpetitrsumrapidemaisu_C14C/image_thumb_1.png" border="0" alt="image" width="244" height="244" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
Mwai, mais encore une foi, comme toute premi&amp;egrave;re m&amp;eacute;thode, elle ne respecte pas la s&amp;eacute;paration du code, qui plus est, si l&amp;#39;on d&amp;eacute;sire afficher diff&amp;eacute;rement des employ&amp;eacute;s &amp;agrave; un endroit de l&amp;#39;interface et &amp;agrave; un autre... ca coince. 
&lt;/p&gt;
&lt;p&gt;
Cette m&amp;eacute;thode ne sera jamais utilis&amp;eacute;e comme m&amp;eacute;thode d&amp;#39;affichage d&amp;eacute;finitive, mais elle peut avoir son utilit&amp;eacute; lors du developement. 
&lt;/p&gt;
&lt;h3&gt;DataTemplate&lt;/h3&gt;
&lt;p&gt;
Voici la fa&amp;ccedil;on la plus belle de rendre lisible tout notre brol. Un DataTemplate est une structure xaml qui sera appliqu&amp;eacute;e &amp;agrave; chacun des items de notre ItemsControl. 
&lt;/p&gt;
&lt;p&gt;
Ici le changement ne se fait que dans le code xaml, l&amp;#39;id&amp;eacute;pendance avec le code behind est parfaite ! 
&lt;/p&gt;
&lt;p&gt;
&lt;div class="code"&gt;
[code:xml]&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Window&lt;/span&gt; &lt;span class="attr"&gt;x:Class&lt;/span&gt;&lt;span class="kwrd"&gt;="SimpleBinding.Window1"&lt;/span&gt;&lt;br /&gt;    &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt;&lt;br /&gt;    &lt;span class="attr"&gt;xmlns:x&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt;&lt;br /&gt;    &lt;span class="attr"&gt;Title&lt;/span&gt;&lt;span class="kwrd"&gt;="Window1"&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="300"&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="300"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Window.Resources&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ObjectDataProvider&lt;/span&gt; &lt;span class="attr"&gt;x:Key&lt;/span&gt;&lt;span class="kwrd"&gt;="myEmployeeList"&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;DataTemplate&lt;/span&gt; &lt;span class="attr"&gt;x:Key&lt;/span&gt;&lt;span class="kwrd"&gt;="EmployeeDataTemplate"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Border&lt;/span&gt; &lt;span class="attr"&gt;CornerRadius&lt;/span&gt;&lt;span class="kwrd"&gt;="5"&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="3"&lt;/span&gt;&lt;br /&gt;                    &lt;span class="attr"&gt;BorderBrush&lt;/span&gt;&lt;span class="kwrd"&gt;="Black"&lt;/span&gt; &lt;span class="attr"&gt;BorderThickness&lt;/span&gt;&lt;span class="kwrd"&gt;="1"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;WrapPanel&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Label&lt;/span&gt; &lt;span class="attr"&gt;Content&lt;/span&gt;&lt;span class="kwrd"&gt;="{Binding Path=Nom}"&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;                    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Label&lt;/span&gt; &lt;span class="attr"&gt;Content&lt;/span&gt;&lt;span class="kwrd"&gt;="{Binding Path=Prenom}"&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;                    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Label&lt;/span&gt; &lt;span class="attr"&gt;Content&lt;/span&gt;&lt;span class="kwrd"&gt;="{Binding Path=Age}"&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;                &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;WrapPanel&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Border&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;DataTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Window.Resources&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ItemsControl&lt;/span&gt; &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;="myItemControl"&lt;/span&gt;&lt;br /&gt;                      &lt;span class="attr"&gt;ItemTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;="{StaticResource EmployeeDataTemplate}"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ItemsControl.ItemsSource&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Binding&lt;/span&gt; &lt;span class="attr"&gt;Source&lt;/span&gt;&lt;span class="kwrd"&gt;="{StaticResource myEmployeeList}"&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ItemsControl.ItemsSource&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ItemsControl&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Window&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;[/code]&lt;/div&gt; 
&lt;/p&gt;
&lt;p&gt;
R&amp;eacute;sultat:&lt;br /&gt;
&lt;a href="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/WPFBindingListtoUIUnpetitrsumrapidemaisu_C14C/image_6.png"&gt;&lt;img style="border: 0px" src="http://www.simonboigelot.com/image.axd?picture=WindowsLiveWriter/WPFBindingListtoUIUnpetitrsumrapidemaisu_C14C/image_thumb_2.png" border="0" alt="image" width="244" height="244" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;
Voil&amp;agrave;, vous avez binder correctement votre liste d&amp;#39;objet, du moins pour ce qui est de l&amp;#39;affichage. Il nous faudra parler de la modification dans un futur proche. 
&lt;/p&gt;
&lt;p&gt;
Quelques autres post pourons vous &amp;ecirc;tre utiles : 
&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;&lt;a href="http://www.simonboigelot.com/post/TemplateSelector-WPF-Xaml.aspx"&gt;TemplateSelector ou comment choisir entre plusieurs DataTemplate dans un m&amp;ecirc;me ItemsControl&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href="http://www.simonboigelot.com/post/Un-ValueConverter-pour-calculer.aspx"&gt;ValueConverter ou comment convertir une valeur en une autre lors du binding&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href="http://www.simonboigelot.com/post/RssReader-en-Pure-Xaml.aspx"&gt;RssReader en Pure Xaml, une belle d&amp;eacute;monstration de la puissance du Binding sous WPF&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://feeds.feedburner.com/~r/SimonBoigelotWorld/~4/181655646" height="1" width="1"/&gt;</description>
      <link>http://feeds.feedburner.com/~r/SimonBoigelotWorld/~3/181655646/post.aspx</link>
      <author>Togis</author>
      <comments>http://www.simonboigelot.com/post/WPF---Binding-List-to-UI---Un-petit-reacute;sumeacute;-rapide-mais-utile.aspx#comment</comments>
      <guid isPermaLink="false">http://www.simonboigelot.com/post.aspx?id=83e06a56-4843-4bf5-9051-06a4cc533be2</guid>
      <pubDate>Thu, 08 Nov 2007 15:17:00 +0200</pubDate>
      <category>WPF</category>
      <category>Binding</category>
      <dc:publisher>Togis</dc:publisher>
      <pingback:server>http://www.simonboigelot.com/pingback.axd</pingback:server>
      <pingback:target>http://www.simonboigelot.com/post.aspx?id=83e06a56-4843-4bf5-9051-06a4cc533be2</pingback:target>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://www.simonboigelot.com/trackback.axd?id=83e06a56-4843-4bf5-9051-06a4cc533be2</trackback:ping>
      <wfw:comment>http://www.simonboigelot.com/post/WPF---Binding-List-to-UI---Un-petit-reacute;sumeacute;-rapide-mais-utile.aspx#comment</wfw:comment>
      <wfw:commentRss>http://www.simonboigelot.com/syndication.axd?post=83e06a56-4843-4bf5-9051-06a4cc533be2</wfw:commentRss>
    <feedburner:origLink>http://www.simonboigelot.com/post.aspx?id=83e06a56-4843-4bf5-9051-06a4cc533be2</feedburner:origLink></item>
    <item>
      <title>WPF Asynchrone et multithread</title>
      <description>&lt;p&gt;Dans une optique de fluïdité d'une application client, nous sommes souvent ammené à séparer les traîtements longs de notre thread charger de l'affichage (appellons-le "thread principal). Nous sommes habitué à ce genre de pratique en Windows Form mais qu'en est-il en WPF?&lt;/p&gt; &lt;h2&gt;Le dispatcher&lt;/h2&gt; &lt;p&gt;Comme vu précédement ( &lt;a href="http://www.simonboigelot.com/post/SystemInvalidOperationException---thread-non-propri%c3%a9taire.aspx"&gt;Fonctionnement du Dispatcher (base)&lt;/a&gt; ), cet objet "manage" l'acces à l'interface de notre application.&lt;/p&gt; &lt;p&gt;Plus précisément voici à quoi il ressemble :&lt;/p&gt; &lt;p&gt;&lt;div class="code"&gt;
[code:c#]&lt;br&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Windows.Threading;&lt;/p&gt; &lt;p&gt;&lt;span class="kwrd"&gt;class&lt;/span&gt; DispatcherObject&lt;br&gt;{&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;public&lt;/span&gt; Dispatcher Dispatcher {get;}&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; CheckAccess();&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; VerifyAcess();&lt;br&gt;}&lt;br&gt;[/code]&lt;/div&gt;&lt;/p&gt; &lt;p&gt;explain check access&lt;/p&gt; &lt;p&gt;explain verifyacces&lt;/p&gt; &lt;h2&gt;Règles de bases&lt;/h2&gt; &lt;p&gt;Lorsque l'on désire multithreader une application, quelle soit WPF ou non, il y a quelques règles à respecter :&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Ne pas toucher à l'interface si l'on n'est pas dans le thread qui la possède !  &lt;li&gt;Ne jamais bloquer le thread qui s'occupe de l'affichage (risque de rendre l'utilisateur fou) !&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;Comment appliquer cette deuxième règles à coup sûr? --&amp;gt; Ne faites jamais rien dans ce thread, lancer toutes vos (longues) opérations en asynchrone !&lt;/p&gt; &lt;h4&gt;Par exemple, voici un longue opération :&lt;/h4&gt; &lt;p&gt;&lt;div class="code"&gt;
[code:c#]&lt;br&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; SlowThing&lt;br&gt;{&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Data&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; get &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Thread.Sleep(10000);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="str"&gt;"hello"&lt;/span&gt;;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;}&lt;br&gt;[/code]&lt;/div&gt;&lt;/p&gt; &lt;h4&gt;Voici ce qu'il ne faut pas faire :&lt;/h4&gt; &lt;p&gt;&lt;div class="code"&gt;
[code:c#]&lt;br&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Button1_OnClick(objetc sender, RoutedEventArg e)&lt;br&gt;{&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SlowThing myST = &lt;span class="kwrd"&gt;new&lt;/span&gt; SlowThing();&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Label1.Text = myST.Data;&lt;br&gt;}&lt;br&gt;[/code]&lt;/div&gt;&lt;/p&gt; &lt;p&gt;Ici, lors du sleep, du "long traîtement" neccessaire à la récupération de notre donnée, l'interface bloquera complettemebt.&lt;/p&gt; &lt;p&gt;Comment résoudre celà ? La méthode la plus simple est sans conteste celle d'utiliser un thread dit worker de notre application.&lt;/p&gt; &lt;p&gt;&lt;div class="code"&gt;
[code:c#]&lt;br&gt;&lt;/p&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Button1_OnClick(objetc sender, RoutedEventArg e)&lt;br&gt;{&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ThreadPool.QueueUserWorkItem(&lt;span class="kwrd"&gt;delegate&lt;/span&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SlowThing myST = &lt;span class="kwrd"&gt;new&lt;/span&gt; SlowThing();&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;string&lt;/span&gt; result = myST.Data;  &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dispatcher.BeginInvoke(DispatcherPriority.Normal, &lt;span class="kwrd"&gt;delegate&lt;/span&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Label1.Text = result;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;br&gt;}&amp;nbsp; &lt;br&gt;[/code]&lt;/div&gt;  &lt;p&gt;Dans un premier temps, on récupère un Thread du pool de l'application, à qui l'on demande de faire le long traîtement.&lt;br&gt;Juste après, on demande au Dispatcher qui gère le thread principal de planifier l'oppération d'affectation de la valeur retrouvée à notre interface.  &lt;h2&gt;DispatcherPriority&lt;/h2&gt; &lt;p&gt;Il existe plusieurs priorités différentes, en voici la liste :&lt;/p&gt; &lt;table cellspacing="0" cellpadding="2" width="546" border="1"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td valign="top" width="132"&gt;Nom de la priorité&lt;/td&gt; &lt;td valign="top" width="412"&gt;Explication&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="132"&gt;SystemIdle&lt;/td&gt; &lt;td valign="top" width="412"&gt;Quand le syteme ne fait rien&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="132"&gt;ApplicationIdle&lt;/td&gt; &lt;td valign="top" width="412"&gt;Quand l'application ne fait rien&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="132"&gt;ContextIdle&lt;/td&gt; &lt;td valign="top" width="412"&gt;Quand toutes les background opérations sont finie&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="132"&gt;Background&lt;/td&gt; &lt;td valign="top" width="412"&gt;Quand les opérations prioritaire sont finie&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="132"&gt;Input&lt;/td&gt; &lt;td valign="top" width="412"&gt;Priorité similaire à celle des inputs&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="132"&gt;Loaded&lt;/td&gt; &lt;td valign="top" width="412"&gt;Quand l'affichage s'est terminé et que la priorité va passer la main aux inputs&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="132"&gt;Render&lt;/td&gt; &lt;td valign="top" width="412"&gt;Priorité similaire à l'affichage&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="132"&gt;DataBind&lt;/td&gt; &lt;td valign="top" width="412"&gt;Priorité similaire au DataBinding&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="132"&gt;Normal&lt;/td&gt; &lt;td valign="top" width="412"&gt;Priorité par défaut, avant le DataBinding&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="132"&gt;Send&lt;/td&gt; &lt;td valign="top" width="412"&gt;Priorité absolue, à faire imédiatement&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h2&gt;DispatcherOperation&lt;/h2&gt; &lt;p&gt;L'opération Dispatcher.BeginInvoke retourne un objet, un DistacherOperaction.&lt;/p&gt; &lt;p&gt;Ce dernier contient quelques informations et méthodes qui peuvent, dans de très rares cas, être utiles, tel que :&lt;/p&gt; &lt;p&gt;Operations : Wait &amp;amp; Abord&lt;br&gt;Properties : Priority, Status &amp;amp; Result&lt;br&gt;Events : Completed &amp;amp; Aborted&lt;/p&gt; &lt;p&gt;Cependant il est fortement déconseillé d'utiliser cet objet.&lt;/p&gt; &lt;p&gt;En effet :&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Wait est stupide en ce qui concerne le thread principal, si le thread principal attend un de ses threads "background", à quoi bon multithreader son application, qui plus est il est très risquer de se retrouver façe à un deadlock...  &lt;li&gt;Completed peut très bien s'implementer de facon beaucoups plus simple, lancer une opération à la fin de notre opération est une idée à creuser ;)&lt;/li&gt;&lt;/ul&gt; &lt;h2&gt;&lt;/h2&gt; &lt;h2&gt;SynchronizationContext&lt;/h2&gt; &lt;p&gt;Le context de synchronisation n'est pas spécific au WPF, en effet, il à fait son apparition dans le .Net 2.0.&lt;br&gt;Son rôle est approximativement de manager les interaction entre différent thread.&lt;/p&gt; &lt;p&gt;Il possède deux méthode importante : &lt;strong&gt;Post &amp;amp; Send&lt;/strong&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;strong&gt;Post &lt;/strong&gt;est la méthode qui va nous permettre de lancer une fonction dans un thread de manière synchrone  &lt;li&gt;&lt;strong&gt;Send&lt;/strong&gt; est la méthode qui va nous permettre de lancer un fonction dans un thread de manière asynchrone&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Pour récuperer le SynchrnizationContext, rien de plus simple :&lt;br&gt;&lt;div class="code"&gt;
[code:c#]&lt;br&gt;SynchronizationContext syncContext = SynchronizationContext.Current;&lt;br&gt;[/code]&lt;/div&gt;&lt;/p&gt; &lt;h2&gt;&lt;/h2&gt; &lt;h2&gt;Chosing Patern&lt;/h2&gt; &lt;p&gt;Dans l'univers du multithread c#, il existe plusieurs méthodes (ou paterns) pour implémenter une situation. Quelles sont ces paterns et lequel choisir pour multithreader une application WPF seront les questions auquelles je vais essayer de répondre ci-dessous.&lt;/p&gt; &lt;h3&gt;.Net 1.1 : begin, end, OnCompleted&lt;/h3&gt; &lt;p&gt;Il s'agit ici de la plus vielle version, elle consiste en 3 phases :&lt;/p&gt; &lt;ol&gt; &lt;li&gt;BeginAction lance une action asyncrhone  &lt;li&gt;Quand cette action asynchrone est lancée l'event OnCompleted arrive au thread principal  &lt;li&gt;EndAction retourne la valeur (l'objet) calculé par l'action asynchrone.&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;Ce patern est totalement intégré à WPF, ce qui fait que, pour l'utiliser, vous n'aurez rien à faire.&lt;/p&gt; &lt;p&gt;Par exemple, si proxy est un proxy accédant à un web service très lent :&lt;br&gt;&lt;div class="code"&gt;
[code:c#]&lt;br&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Button1_OnClick(objetc sender, RoutedEventArg e)&lt;br&gt;{&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proxy.BeginGetData(param, OnGetDataComplete, &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;br&gt;}&lt;br&gt;&lt;br&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; OnGetDataCompleted(IAsyncResult iar)&lt;br&gt;{&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dara reult = proxy.EndGetData();&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; resultBox.Text = result;&lt;br&gt;}&lt;br&gt;[/code]&lt;/div&gt;&lt;/p&gt; &lt;p&gt;Mais, OnGetDataCompleted est toujours exécuté dans le thrad principal, ce qui ne nou aide qu'à moitier.&lt;br&gt;Pour éviter ce problème, nous pourrons réutiliser Dispatcher.BeginInvoke dans le OnGetDataCompleted....&lt;br&gt;C'est donc utilisable, mais pas le plus simple.&lt;/p&gt; &lt;h3&gt;.Net 2 : Event-based async&lt;/h3&gt; &lt;p&gt;Ceci est un bien meilleur choix en ce qui concerne le WPF.&lt;br&gt;Cependant il n'est pas intégré à WPF pour le moment, mais nous pouvons nous même implementer ce modèle.&lt;/p&gt; &lt;p&gt;Premièrement, comment fonctionne-t-il ?&lt;br&gt;&lt;div class="code"&gt;
[code:c#]&lt;br&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Button1_OnClick(objetc sender, RoutedEventArg e)&lt;br&gt;{&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; WebClient downloader = &lt;span class="kwrd"&gt;new&lt;/span&gt; WebClient();&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; downloader.DownloadDataCompleted += &lt;span class="kwrd"&gt;new&lt;/span&gt; DownloadDataCompletedEventHandler(downloader_DownloadDataCompleted);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; downloader.DownloadDataAsync(&lt;span class="kwrd"&gt;new&lt;/span&gt; Uri(&lt;span class="str"&gt;"&lt;a href="&lt;/span&gt;http://www.simonboigelot.com&amp;quot;));&lt;span class="str"&gt;"&gt;http://www.simonboigelot.com"&lt;/span&gt;));&lt;/a&gt;&lt;br&gt;} &lt;/p&gt; &lt;p&gt;&lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; downloader_DownloadDataCompleted(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, DownloadDataCompletedEventArgs e)&lt;br&gt;{&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;byte&lt;/span&gt;[] result = e.Result;&lt;br&gt;}&lt;br&gt;[/code]&lt;/div&gt;  &lt;p&gt;Pourquoi es-ce un meilleur choix, me direz-vous? &lt;/p&gt; &lt;p&gt;Et bien, DownloadDateCompleted est automatiquement exécuté dans un thread différent du thread principal ! (Contrairement au patern précédent)&lt;/p&gt; &lt;p&gt;Malheureusement, ce patern n'est pas disponible de base dans WPF. Comment faire alors? Nous allons écrire une class d'encapsulation au dessu de notre service lent : &lt;br&gt;&lt;div class="code"&gt;
[code:c#]&lt;br&gt;&lt;span class="kwrd"&gt;class&lt;/span&gt; ServiceWraper&lt;br&gt;{&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SlowService proxi = &lt;span class="kwrd"&gt;new&lt;/span&gt; SlowService();&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; GetDataAsync(&lt;span class="kwrd"&gt;object&lt;/span&gt; param)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SynchronizationContext callerContext = SynchronizationContext.Current;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proxy.BeginGetData(param, ProxyCallBack, callerContext);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;/p&gt; &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; ProxyCallback(IAsynResult iar)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;int&lt;/span&gt; result = proxy.EndGetData(iar);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SynchronizationContext callerContext =&amp;nbsp; iar.AsynState;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; callerContext.Post(RaiseEvent, result);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; RaiseEvent(&lt;span class="kwrd"&gt;int&lt;/span&gt; result)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;if&lt;/span&gt;(OnGetDataCompleted != &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OnGetDataCompleted(&lt;span class="kwrd"&gt;new&lt;/span&gt; GetDataCompletedEventArg (result));&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;event&lt;/span&gt; EventHandler&amp;lt;GetDataCompletedEventArg&amp;gt; OnGetDataCompleted;&lt;br&gt;}&lt;br&gt;[/code]&lt;/div&gt;&lt;br&gt;&lt;br&gt;Utiliser notre service se fera alors exactement comme utiliser un WebClient :&lt;br&gt;&lt;div class="code"&gt;
[code:c#]&lt;br&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Button1_OnClick(objetc sender, RoutedEventArg e)&lt;br&gt;{&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ServiceWraper downloader = &lt;span class="kwrd"&gt;new&lt;/span&gt; ServiceWraper();&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; downloader.OnGetDataCompleted+= &lt;span class="kwrd"&gt;new&lt;/span&gt; OnGetDataCompletedEventHandler(downloader_OnGetDataCompleted);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; downloader.GetDataAsync(param&lt;a href=&lt;span class="str"&gt;"http://www.simonboigelot.co