<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Paul King's BLOG</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/paulking/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/paulking/feed.xml</link>
    <description>Looking for an answer to the question you have found.</description>
    <lastBuildDate>Tue, 16 Apr 2019 05:24:15 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>GRS/RA-GRS in Azure and how to plan for DR</title>
      <link>https://docs.microsoft.com/archive/blogs/paulking/storage-in-azure-and-how-to-plan-for-dr</link>
      <pubDate>Fri, 15 Apr 2016 11:19:29 GMT</pubDate>
      <dc:creator><![CDATA[Paul King - msft]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/paulking/?p=315</guid>
      <description><![CDATA[I was having a discussion yesterday and realized I had a gap in my knowledge on how to recover from...]]></description>
      <content:encoded><![CDATA[I was having a discussion yesterday and realized I had a gap in my knowledge on how to recover from a disaster using storage. I did some research, and I want to share this with everyone.  Plus it has been ages since I've shared anything new here.

<a title="This is the best source I’ve seen on the details of our Storage story for DR" href="https://azure.microsoft.com/en-us/documentation/articles/storage-redundancy/" target="_blank">This is the best source I’ve seen on the details of our Storage story for DR</a> and from there, there is <a title="this link" href="https://blogs.msdn.microsoft.com/windowsazurestorage/2013/12/11/windows-azure-storage-redundancy-options-and-read-access-geo-redundant-storage/" target="_blank">this link</a> that goes into even more detail.

The article doesn’t explain as much as I would like, but the details come through in the comments of the first and the detail of the second links.

Comment from first:

<em>It is important to note that GRS does not fail over to the secondary location unless there is TOTAL data center outage. If a few clusters are down and you are affected you may find yourself dead in the water without a paddle until those clusters are fixed. We just found ourselves in this situation and don't believe it is clearly stated as it should be. We basically spent the $1000 professional direct support only to be told that fail over was not an option due to only a couple of clusters ( including ours) being affected. If you want true Geo Redundancy in the event of a cluster issue you have to implement it yourself.</em>

So based on the above, the customer does not have the ability to make this switch today, Microsoft makes the determination of making the switch. This is discussed in the second article:

<em><strong>Recovery Time Objective (RTO)</strong>: The other metric to know about is RTO. This is a measure of how long it takes us to do the failover, and get the storage account back online if we had to do a failover. The time to do the failover includes the following:</em>
<ul>
	<li><i>The time it takes us to investigate and determine whether we can recover the data at the primary location or if we should do the failover</i></li>
	<li><i>Failover the account by changing the DNS entries</i></li>
</ul>
<em>We take the responsibility of preserving your data very seriously, so if there is any chance of recovering the data, we will hold off on doing the failover and focus on recovering the data in the primary location. <strong>In the future, we plan to provide an API to allow customers to trigger a failover at an account level</strong>, which would then allow customers to control the RTO themselves, but this is not available yet.</em>

You can have more control of this if you use RA-GRS.

Comment from the first article:

<em>The VHD is replicated to the secondary site. You can not use the VHD to create a VM, because the secondary is read-only. You would have to copy it to a storage account in a primary data center to create a VM from it. Of course, as discussed in your previous question, if something catastrophic happened and the secondary became the primary, you could create a VM from the VHD file. This redundancy feature is about storage, and only storage, not about recreating your VMs and everything that uses something in storage. You might want to check out Azure Backup for something like that.</em>

So how do I move my VM to a different data center and start to use my replicated storage myself in the case of an outage?
<ol>
	<li>Use RA-GRS</li>
	<li><a title="Find the IP location of your &lt;storage account&gt;-secondary endpoint" href="https://blogs.msdn.microsoft.com/paulking/2016/04/15/design-your-storage-for-high-availability-in-azure/" target="_blank">Find the IP location of your &lt;storage account&gt;-secondary endpoint</a></li>
	<li>Create a new storage account on that same stamp/IP if possible or a different stamp in the same data center the -secondary is located in</li>
	<li>Use the secondary endpoint on the RA-GRS to copy the blob to the new storage account created above making it a writable copy</li>
	<li>Deploy your VM to that new data center (preferably through script) and bring it back up using the new storage.</li>
</ol>
Note that there are still a few other things to consider.
<ol>
	<li>If you can’t get on the same stamp the RA-GRS uses, then copies between stamps in the same data center take time. <a title="See this article" href="https://www.opsgility.com/blog/windows-azure-powershell-reference-guide/copying-vhds-blobs-between-storage-accounts/" target="_blank">See this article</a> - there is a chart there that detail the time to copy between stamps and data centers.</li>
	<li>Recovery Point Objective is 15 minutes for RA-GRS, but there is no SLA on Geo-replication, so there may be some data loss since Geo-Replication is asynchronous. <a title="From another blog post:" href="https://blogs.msdn.microsoft.com/windowsazurestorage/2013/12/11/windows-azure-storage-redundancy-options-and-read-access-geo-redundant-storage/" target="_blank">From another blog post:</a>
<ol>
	<li><strong>Recover Point Objective (RPO)</strong>: In GRS and RA-GRS the storage service asynchronously geo-replicates the data from the primary to the secondary location. If there was a major regional disaster and a failover had to be performed, then recent delta changes that had not been geo-replicated could be lost. The number of minutes of potential data lost is referred to as RPO (i.e., the point in time to which data can be recovered to). We typically have a RPO less than 15 minutes, though there is currently no SLA on how long geo-replication takes.</li>
</ol>
</li>
</ol>
Most of this information comes from BLOGs and the actual functionality is a moving target, so keeping up to date is an issue.  Please comment as things change.]]></content:encoded>
    </item>
    <item>
      <title>Error trying to get the NuGet package source, https://nuget.org/api/v2, through the NuGet Package Manager tool for Visual Studio</title>
      <link>https://docs.microsoft.com/archive/blogs/paulking/error-trying-to-get-the-nuget-package-source-httpsnuget-orgapiv2-through-the-nuget-package-manager-tool-for-visual-studio</link>
      <pubDate>Thu, 05 Sep 2013 04:09:00 GMT</pubDate>
      <dc:creator><![CDATA[Paul King - msft]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/paulking/2013/09/05/error-trying-to-get-the-nuget-package-source-httpsnuget-orgapiv2-through-the-nuget-package-manager-tool-for-visual-studio/</guid>
      <description><![CDATA[Recently my customer kept getting the following error when they were trying to connect to the NuGet...]]></description>
      <content:encoded><![CDATA[<p>Recently my customer kept getting the following error when they were trying to connect to the NuGet package source through the Package Manager tool in Visual Studio:</p>
<p><em><span style="color: black; font-family: 'Tahoma','sans-serif'; font-size: 10pt; mso-fareast-font-family: PMingLiU; mso-fareast-theme-font: minor-fareast; mso-ansi-language: EN-US; mso-fareast-language: ZH-TW; mso-bidi-language: AR-SA;">"ServicePointManager doesn't support proxies with https scheme"</span></em></p>
<p><span style="color: black; font-family: tahoma,arial,helvetica,sans-serif; font-size: 10pt; mso-fareast-font-family: PMingLiU; mso-fareast-theme-font: minor-fareast; mso-ansi-language: EN-US; mso-fareast-language: ZH-TW; mso-bidi-language: AR-SA;">This was odd since they did not specify https as the scheme for their proxy.&nbsp; Instead, they had specified their proxy specifically in their devenv.exe.config file as <a href="https://myproxy.corp.com">https://myproxy.corp.com</a> </span></p>
<p><span style="color: black; font-family: tahoma,arial,helvetica,sans-serif; font-size: 10pt; mso-fareast-font-family: PMingLiU; mso-fareast-theme-font: minor-fareast; mso-ansi-language: EN-US; mso-fareast-language: ZH-TW; mso-bidi-language: AR-SA;">Turns out that the Package Manager tool in Visual Studio uses the proxy set in IE when it tries to connect to the NuGet package source.&nbsp; In this particular environment&nbsp;the client proxies were being set by IEAK and had INS file settings that looked like this:</span></p>
<p>&nbsp;</p>
<p><span style="font-family: courier new,courier;">[Proxy]</span></p>
<p><span style="font-family: courier new,courier;">HTTP_Proxy_Server=proxy.corp.com:8235</span></p>
<p><span style="font-family: courier new,courier;">FTP_Proxy_Server=proxy.corp.com:8235</span></p>
<p><span style="font-family: courier new,courier;">Secure_Proxy_Server=proxy.corp.com:8235</span></p>
<p><span style="font-family: courier new,courier;">Socks_Proxy_Server=proxy.corp.com:8235</span></p>
<p><span style="font-family: courier new,courier;">Use_Same_Proxy=1</span></p>
<p><span style="font-family: courier new,courier;">Proxy_Enable=1</span></p>
<p>&nbsp;</p>
<p><span style="color: black; font-family: tahoma,arial,helvetica,sans-serif; font-size: 10pt; mso-fareast-font-family: PMingLiU; mso-fareast-theme-font: minor-fareast; mso-ansi-language: EN-US; mso-fareast-language: ZH-TW; mso-bidi-language: AR-SA;">The problem was that the scheme was not specified.&nbsp; To correct this, the proxies listed in the INS file should have looked like this:</span></p>
<p>&nbsp;</p>
<p><span style="font-family: courier new,courier;">[Proxy]</span></p>
<p><span style="font-family: courier new,courier;">HTTP_Proxy_Server=https://proxy.corp.com:8235</span></p>
<p><span style="font-family: courier new,courier;">FTP_Proxy_Server=https://proxy.corp.com:8235</span></p>
<p><span style="font-family: courier new,courier;">Secure_Proxy_Server=https://proxy.corp.com:8235</span></p>
<p><span style="font-family: courier new,courier;">Socks_Proxy_Server=https://proxy.corp.com:8235</span></p>
<p><span style="font-family: courier new,courier;">Use_Same_Proxy=1</span></p>
<p><span style="font-family: courier new,courier;">Proxy_Enable=1</span></p>
<p>&nbsp;</p>
<p>This issue was originally BLOG'd about by <a title="Jeff Sanders" href="https://blogs.msdn.com/b/jpsanders/archive/2007/04/25/the-servicepointmanager-does-not-support-proxies-of-https-scheme-net-1-1-sp1.aspx">Jeff Sanders</a>&nbsp;<span>and pointed out to me by Tim Lovell-Smith.&nbsp; Thanks for the help!</span></p>
<p>&nbsp;</p>]]></content:encoded>
    </item>
    <item>
      <title>Trying to obtain the proxy of a WebRequest throws an exception</title>
      <link>https://docs.microsoft.com/archive/blogs/paulking/trying-to-obtain-the-proxy-of-a-webrequest-throws-an-exception</link>
      <pubDate>Tue, 13 Aug 2013 04:11:00 GMT</pubDate>
      <dc:creator><![CDATA[Paul King - msft]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/paulking/2013/08/13/trying-to-obtain-the-proxy-of-a-webrequest-throws-an-exception/</guid>
      <description><![CDATA[The example of the WebRequest.Proxy property on MSDN&nbsp;shows this code:
 // Create a new request...]]></description>
      <content:encoded><![CDATA[<p>The example of the WebRequest.Proxy property on <a title="MSDN" href="https://msdn.microsoft.com/en-us/library/system.net.webrequest.proxy.aspx" target="_blank">MSDN</a>&nbsp;shows this code:</p>
<pre class="scroll"><code class="csharp"> // Create a new request to the mentioned URL.<br /> WebRequest myWebRequest=WebRequest.Create("https://www.contoso.com");<br /> <br /> WebProxy myProxy=new WebProxy();<br /> <br /> // Obtain the Proxy Prperty of the Default browser. <br /> myProxy=(WebProxy)myWebRequest.Proxy;<br /> <br /> </code></pre>
<p>that throws the following exception on the last line of code when you run it:</p>
<p>"Unable to cast object of type 'WebProxyWrapper' to type 'System.Net.WebProxy'"</p>
<p>If you need to get the code to work without the exception, try this:</p>
<pre class="scroll"><code class="csharp"> Uri address = new Uri(<a href="https://www.bing.com">https://www.bing.com</a>);<br /> HttpWebRequest request = (HttpWebRequest)WebRequest.Create(address);<br /> IWebProxy myProxy = request.Proxy;<br /> Uri proxyUri = myProxy.GetProxy(address);<br /></code></pre>
<p>Note, if there is no proxy set, the proxy returned in proxyUri will be equal to the URL address.&nbsp; You can confirm this though a simple comparison of the URIs like this:</p>
<pre class="scroll"><code class="csharp">if (address.Equals(proxyUri))</code></pre>
<p>&nbsp;I will link the MSDN article to this BLOG so that the documentation can be corrected.</p>
<p>&nbsp;</p>]]></content:encoded>
    </item>
    <item>
      <title>Using Azure?  If you reinstall the OS, be sure to backup and restore your documents directory</title>
      <link>https://docs.microsoft.com/archive/blogs/paulking/using-azure-if-you-reinstall-the-os-be-sure-to-backup-and-restore-your-documents-directory</link>
      <pubDate>Thu, 21 Feb 2013 07:52:00 GMT</pubDate>
      <dc:creator><![CDATA[Paul King - msft]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/paulking/2013/02/21/using-azure-if-you-reinstall-the-os-be-sure-to-backup-and-restore-your-documents-directory/</guid>
      <description><![CDATA[Ever wonder where the settings for your Windows Azure subscriptions are stored?

In Visual Studio,...]]></description>
      <content:encoded><![CDATA[<p>Ever wonder where the settings for your Windows Azure subscriptions are stored?</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/41/44/6330.Storage%20Account.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-41-44/6330.Storage-Account.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/41/44/6330.Storage%20Account.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x506/__key/communityserver-blogs-components-weblogfiles/00-00-01-41-44/6330.Storage-Account.png" alt="" border="0" /></a></p>
<p>In Visual Studio, under Server Explorer, when you have the Azure tools installed you can use it to connect to a Storage Account in Windows Azure.&nbsp; When you configuring it, there is an option called &ldquo;Remember account key&rdquo;.&nbsp; Visual Studio keeps those settings for Azure in a file located in the following directory:</p>
<p>C:\Users\&lt;username&gt;\Documents\Visual Studio 2012\Settings\Windows Azure Connections.xml</p>
<p>If you backup and restored this file before reinstalling the OS, it would have everything it needs to connect to Azure on your behalf and get the list of storage accounts directly.&nbsp; Once it has the thumbprint information associated with the subscription ID, it connects to the management portal directly using the Management API.</p>
<p>&nbsp;</p>]]></content:encoded>
    </item>
    <item>
      <title>Importing Test Cases with required fields</title>
      <link>https://docs.microsoft.com/archive/blogs/paulking/importing-test-cases-with-required-fields</link>
      <pubDate>Wed, 13 Feb 2013 07:04:00 GMT</pubDate>
      <dc:creator><![CDATA[Paul King - msft]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/paulking/2013/02/13/importing-test-cases-with-required-fields/</guid>
      <description><![CDATA[Recently I saw that trying to use TCM testcases /import to pull in test cases for test methods in a...]]></description>
      <content:encoded><![CDATA[<p>Recently I saw that trying to use TCM testcases /import to pull in test cases for test methods in a DLL has some issues if the work item template is modified.&nbsp; TCM was failing to create the test cases because the template had two items that were marked as required that were being set by referencing a field that was not set when the test case is first saved.&nbsp; Below is an example of this scenario.</p>
<p>&nbsp;</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/41/44/0250.fisrt.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-41-44/0250.fisrt.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/41/44/0250.fisrt.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x460/__key/communityserver-blogs-components-weblogfiles/00-00-01-41-44/0250.fisrt.png" alt="" border="0" /></a></p>
<p>We found that the Microsoft.VSTS.TCM.AutomationStatus field was not a valid field to test when setting default values.&nbsp; Instead, if you check for Microsoft.VSTS.TCM.AutomatedTestId, then you will be able to set your defaults.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/41/44/1033.second.PNG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-41-44/1033.second.PNG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/41/44/1033.second.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x399/__key/communityserver-blogs-components-weblogfiles/00-00-01-41-44/1033.second.PNG" alt="" border="0" /></a></p>]]></content:encoded>
    </item>
    <item>
      <title>Making the ExpanderView more responsive with lots of items</title>
      <link>https://docs.microsoft.com/archive/blogs/paulking/making-the-expanderview-more-responsive-with-lots-of-items</link>
      <pubDate>Tue, 03 Apr 2012 06:35:00 GMT</pubDate>
      <dc:creator><![CDATA[Paul King - msft]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/paulking/2012/04/03/making-the-expanderview-more-responsive-with-lots-of-items/</guid>
      <description><![CDATA[If you haven&rsquo;t already checked it out, the Silverlight for Windows Phone Toolkit contains a...]]></description>
      <content:encoded><![CDATA[<p><span style="font-size: small;">If you haven&rsquo;t already checked it out, the <a href="https://silverlight.codeplex.com/releases/view/75888#DownloadId=304100"><span style="color: #0000ff;" color="#0000ff">Silverlight for Windows Phone Toolkit</span></a> contains a rich set of additional controls to make your life easier when programming the Windows Phone.&nbsp; Not to be missed is the sample application you can download separately that allows you to play around with the controls in the toolkit.&nbsp; The sample I&rsquo;m going to dive a little deeper into today is the ExpanderView.&nbsp; As the sample declares, the ExpanderView shows sub-items similar to the way the Outlook application does; allowing you to drill down into nested items.</span></p>
<p><br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/41/44/3683.image%201.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-41-44/3683.image-1.png"><img border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/41/44/3683.image%201.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-41-44/3683.image-1.png" /></a></p>
<p></p>
<p><span style="font-size: small;" size="3"><span style="font-family: Calibri;" face="Calibri">The items in the view are created from a binding to the Data\InboxObject.&nbsp; The sample only shows three conversations with a couple of messages in each conversation.&nbsp; I&rsquo;m going to shorten the text of the conversations here so that they can be displayed on single lines in this BLOG.</span></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas; color: green;">// (c) Copyright Microsoft Corporation.</span><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas; color: green;">// This source is subject to the Microsoft Public License (Ms-PL).</span><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas; color: green;">// Please see https://go.microsoft.com/fwlink/?LinkID=131993 for details.</span><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas; color: green;">// All other rights reserved.</span><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><o:p>&nbsp;</o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas; color: blue;">using</span><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"> System.Collections.ObjectModel;<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><o:p>&nbsp;</o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas; color: blue;">namespace</span><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"> PhoneToolkitSample.Data<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;">{<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">InboxObject</span> : <span style="color: #2b91af;"> ObservableCollection</span>&lt;<span style="color: #2b91af;">ConversationObject</span>&gt;<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">public</span> InboxObject() : <span style="color: blue;">base</span>()<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #2b91af;">ConversationObject</span> one = <span style="color: blue;">new</span> <span style="color: #2b91af;"> ConversationObject</span>(<span style="color: #a31515;">"3 messages, 0 unread"</span>);<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>one.Add(<span style="color: blue;">new</span> <span style="color: #2b91af;"> EmailObject</span>(<span style="color: #a31515;">"Anne Wallace"</span>, <span style="color: #a31515;">"Lunch Today?"</span>, <span style="color: #a31515;"> "Sure!"</span>));<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>one.Add(<span style="color: blue;">new</span> <span style="color: #2b91af;"> EmailObject</span>(<span style="color: #a31515;">"Me"</span>, <span style="color: #a31515;">"Lunch Today?"</span>, <span style="color: #a31515;"> "OK, ask Dave?"</span>));<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>one.Add(<span style="color: blue;">new</span> <span style="color: #2b91af;"> EmailObject</span>(<span style="color: #a31515;">"Bruno Denuit"</span>, <span style="color: #a31515;">"Lunch Today?"</span>, <span style="color: #a31515;"> "I vote for Thai."</span>));<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><o:p>&nbsp;</o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #2b91af;">ConversationObject</span> two = <span style="color: blue;">new</span> <span style="color: #2b91af;"> ConversationObject</span>(<span style="color: #a31515;">"1 messages, 0 unread"</span>);<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>two.Add(<span style="color: blue;">new</span> <span style="color: #2b91af;"> EmailObject</span>(<span style="color: #a31515;">"Adriana Giorgi"</span>, <span style="color: #a31515;">"Fun trip?"</span>, <span style="color: #a31515;"> "Lucky you ..."</span>));<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><o:p>&nbsp;</o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #2b91af;">ConversationObject</span> three = <span style="color: blue;">new</span> <span style="color: #2b91af;"> ConversationObject</span>(<span style="color: #a31515;">"4 messages, 1 unread"</span>);<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>three.Add(<span style="color: blue;">new</span> <span style="color: #2b91af;"> EmailObject</span>(<span style="color: #a31515;">"Belinda Newman"</span>, <span style="color: #a31515;">"hawaii pics!"</span>, <span style="color: #a31515;"> "Good times."</span>));<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>three.Add(<span style="color: blue;">new</span> <span style="color: #2b91af;"> EmailObject</span>(<span style="color: #a31515;">"Richard Carey"</span>, <span style="color: #a31515;">"hawaii pics!"</span>, <span style="color: #a31515;"> "Cool fish."</span>));<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>three.Add(<span style="color: blue;">new</span> <span style="color: #2b91af;"> EmailObject</span>(<span style="color: #a31515;">"Christof Sprenger"</span>, <span style="color: #a31515;">"hawaii pics!"</span>, <span style="color: #a31515;"> "Can't wait to get back."</span>));<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>three.Add(<span style="color: blue;">new</span> <span style="color: #2b91af;"> EmailObject</span>(<span style="color: #a31515;">"Melissa Kerr"</span>, <span style="color: #a31515;">"hawaii pics!"</span>, <span style="color: #a31515;"> "Check it and tag"</span>));<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><o:p>&nbsp;</o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Add(one);<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Add(two);<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Add(three);<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>}<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;">}<o:p></o:p></span></p>
<p>&nbsp;</p>
<p><span style="font-size: small;">Now, what happens if you have 60 conversations you need to display instead of three?&nbsp; A slight modification to the code will get us there:</span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas; color: blue;">public</span><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"> <span style="color: blue;">class</span> <span style="color: #2b91af;">InboxObject</span> : <span style="color: #2b91af;">ObservableCollection</span>&lt;<span style="color: #2b91af;">ConversationObject</span>&gt;<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;">{<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">public</span> InboxObject() : <span style="color: blue;">base</span>()<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">for</span> (<span style="color: blue;">int</span> i = 0; i &lt; 20; i++)<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #2b91af;">ConversationObject</span> one = <span style="color: blue;">new</span> <span style="color: #2b91af;"> ConversationObject</span>(<span style="color: #a31515;">"3 messages, 0 unread"</span>);<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>one.Add(<span style="color: blue;">new</span> <span style="color: #2b91af;"> EmailObject</span>(<span style="color: #a31515;">"Anne Wallace"</span>, <span style="color: #a31515;">"Lunch Today?"</span>, <span style="color: #a31515;"> "Sure!"</span>));<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>one.Add(<span style="color: blue;">new</span> <span style="color: #2b91af;"> EmailObject</span>(<span style="color: #a31515;">"Me"</span>, <span style="color: #a31515;">"Lunch Today?"</span>, <span style="color: #a31515;"> "OK, ask Dave?"</span>));<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>one.Add(<span style="color: blue;">new</span> <span style="color: #2b91af;"> EmailObject</span>(<span style="color: #a31515;">"Bruno Denuit"</span>, <span style="color: #a31515;">"Lunch Today?"</span>, <span style="color: #a31515;"> "I vote for Thai."</span>));<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><o:p>&nbsp;</o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #2b91af;">ConversationObject</span> two = <span style="color: blue;">new</span> <span style="color: #2b91af;"> ConversationObject</span>(<span style="color: #a31515;">"1 messages, 0 unread"</span>);<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>two.Add(<span style="color: blue;">new</span> <span style="color: #2b91af;"> EmailObject</span>(<span style="color: #a31515;">"Adriana Giorgi"</span>, <span style="color: #a31515;">"Fun trip?"</span>, <span style="color: #a31515;"> "Lucky you ..."</span>));<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><o:p>&nbsp;</o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #2b91af;">ConversationObject</span> three = <span style="color: blue;">new</span> <span style="color: #2b91af;"> ConversationObject</span>(<span style="color: #a31515;">"4 messages, 1 unread"</span>);<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>three.Add(<span style="color: blue;">new</span> <span style="color: #2b91af;"> EmailObject</span>(<span style="color: #a31515;">"Belinda Newman"</span>, <span style="color: #a31515;">"hawaii pics!"</span>, <span style="color: #a31515;"> "Good times."</span>));<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>three.Add(<span style="color: blue;">new</span> <span style="color: #2b91af;"> EmailObject</span>(<span style="color: #a31515;">"Richard Carey"</span>, <span style="color: #a31515;">"hawaii pics!"</span>, <span style="color: #a31515;"> "Cool fish."</span>));<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>three.Add(<span style="color: blue;">new</span> <span style="color: #2b91af;"> EmailObject</span>(<span style="color: #a31515;">"Christof Sprenger"</span>, <span style="color: #a31515;">"hawaii pics!"</span>, <span style="color: #a31515;"> "Can't wait to get back."</span>));<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>three.Add(<span style="color: blue;">new</span> <span style="color: #2b91af;"> EmailObject</span>(<span style="color: #a31515;">"Melissa Kerr"</span>, <span style="color: #a31515;">"hawaii pics!"</span>, <span style="color: #a31515;"> "Check it and tag"</span>));<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><o:p>&nbsp;</o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Add(one);<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Add(two);<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Add(three);<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>}<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;">}</span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal">&nbsp;</p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><br />&nbsp;</p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;" size="3"><span face="Calibri">In the emulator runs the code runs without any problem.&nbsp; My Windows Phone 7 device is an LG Quantum and running this code there took 11-14 seconds.&nbsp; That&rsquo;s 11-14 seconds of the user staring at a blank screen.&nbsp; My guess this isn&rsquo;t the smooth slick user experience you want your users to have, so how do you go about fixing that?&nbsp; </span></span><br /><span style="font-family: arial,helvetica,sans-serif; font-size: small;" size="3"><span face="Calibri"></span></span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;" size="3"><span face="Calibri">Digging into the sample, the first thing I did was profile the application on the device itself.&nbsp; It was pretty clear that the UI thread was the culprit (MeasureOverride to be specific).&nbsp; The UI control calculates its layout every time you add an individual item; there currently isn&rsquo;t a way around this.&nbsp; What I needed was an AsyncObservableCollection that could be smart enough to load the items of the collection when the UI was idle.&nbsp; But how do you detect that the UI is idle on the WP7?&nbsp; </span></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: arial,helvetica,sans-serif; font-size: small; mso-bidi-font-size: 9.5pt;">On the WP7 device, when the UI is inactive, there are no spinning cycles, so if there is no work to do, then nothing is done.&nbsp; In the above code, all of the items are being created and added all on the UI thread, so the application isn&rsquo;t responsive until the code completes.&nbsp; Additionally, using a construct like Deployment.Current.Dispatcher.BeginInvoke doesn&rsquo;t help us either since doing this will still create all the objects on the UI thread and then queue the additions to the UI thread as soon as we complete.&nbsp; What we need is a way to put the items onto the UI thread after we&rsquo;ve created them a little at a time so as not to block the UI thread from user input.&nbsp; That&rsquo;s where AsyncObservableCollection comes in.</span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal">&nbsp;</p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas; color: green;"> //-----------------------------------------------------------------------------</span><span style="font-size: 8.0pt; font-family: Consolas;"><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas; color: green;">//</span><span style="font-size: 8.0pt; font-family: Consolas;"><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas; color: green;">// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF</span><span style="font-size: 8.0pt; font-family: Consolas;"><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas; color: green;">// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO</span><span style="font-size: 8.0pt; font-family: Consolas;"><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas; color: green;">// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A</span><span style="font-size: 8.0pt; font-family: Consolas;"><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas; color: green;">// PARTICULAR PURPOSE.</span><span style="font-size: 8.0pt; font-family: Consolas;"><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas; color: green;">//</span><span style="font-size: 8.0pt; font-family: Consolas;"><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas; color: green;">// Copyright (c) Microsoft Corporation. All rights reserved.</span><span style="font-size: 8.0pt; font-family: Consolas;"><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas; color: green;">//</span><span style="font-size: 8.0pt; font-family: Consolas;"><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas; color: green;">//</span><span style="font-size: 8.0pt; font-family: Consolas;"><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas; color: green;"> //-----------------------------------------------------------------------------</span><span style="font-size: 8.0pt; font-family: Consolas;"><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><o:p>&nbsp;</o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas; color: blue;">using</span><span style="font-size: 8.0pt; font-family: Consolas;"> System.Collections.Generic;<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas; color: blue;">using</span><span style="font-size: 8.0pt; font-family: Consolas;"> System.Collections.ObjectModel;<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas; color: blue;">using</span><span style="font-size: 8.0pt; font-family: Consolas;"> System.Linq;<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas; color: blue;">using</span><span style="font-size: 8.0pt; font-family: Consolas;"> System.Threading;<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas; color: blue;">using</span><span style="font-size: 8.0pt; font-family: Consolas;"> System.Windows;<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas; color: blue;">using</span><span style="font-size: 8.0pt; font-family: Consolas;"> System.ComponentModel;<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas; color: blue;">using</span><span style="font-size: 8.0pt; font-family: Consolas;"> System;<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><o:p>&nbsp;</o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas; color: blue;">namespace</span><span style="font-size: 8.0pt; font-family: Consolas;"> PhoneToolkitSample.Data<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;">{<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span> <span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">AsyncObservableCollection</span>&lt;T&gt; : <span style="color: #2b91af;">ObservableCollection</span>&lt;T&gt;<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: green;">// Only one of these should exist for all instances</span><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">static</span> <span style="color: #2b91af;"> AutoResetEvent</span> myEvent = <span style="color: blue;">null</span>;<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><o:p>&nbsp;</o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">public</span> <span style="color: blue;">void</span> FillAsync(<span style="color: #2b91af;">IEnumerable</span>&lt;T&gt; list)<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: green;">// Create event on first use</span><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">if</span> (<span style="color: blue;">null</span> == myEvent)<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>myEvent = <span style="color: blue;">new</span> <span style="color: #2b91af;"> AutoResetEvent</span>(<span style="color: blue;">false</span>);<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><o:p>&nbsp;</o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #2b91af;">Thread</span> t = <span style="color: blue;"> new</span> <span style="color: #2b91af;">Thread</span>(<span style="color: blue;">new</span> <span style="color: #2b91af;">ThreadStart</span>(() =&gt;<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: green;">// First wait is to pause the thread to allow non-bound </span><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: green;">// actions to transition into view on the UI thread.</span><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>WaitForUI();<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><o:p>&nbsp;</o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">int</span> i = 0;<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><o:p>&nbsp;</o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">foreach</span> (T item <span style="color: blue;"> in</span> list)<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>T copy = list.ElementAt(i);<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #2b91af;">Deployment</span>.Current.Dispatcher.BeginInvoke(() =&gt; { <span style="color: blue;">this</span>.Add(copy); });<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>WaitForUI();<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>i++;<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}));<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>t.Name = <span style="color: #a31515;">"FillAsync"</span>;<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>t.Start();<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><o:p>&nbsp;</o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">private</span> <span style="color: blue;">void</span> WaitForUI()<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: green;">// Wait for the UI thread to free up before adding another</span><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #2b91af;">Deployment</span>.Current.Dispatcher.BeginInvoke(() =&gt; { UIFree(); });<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>myEvent.WaitOne();<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><o:p>&nbsp;</o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: green;">// A short sleep to stay responsive on the UI thread</span><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #2b91af;">Thread</span>.Sleep(10);<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><o:p>&nbsp;</o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">public</span> <span style="color: blue;">void</span> UIFree()<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: green;">// Called on the UI thread as soon as the add is completed</span><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>myEvent.Set();<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>}<o:p></o:p></span></p>
<p><span style="font-size: 8.0pt; line-height: 115%; font-family: Consolas; mso-fareast-font-family: PMingLiU; mso-fareast-theme-font: minor-fareast; mso-ansi-language: EN-US; mso-fareast-language: ZH-TW; mso-bidi-language: AR-SA;">}</span></p>
<p><span style="line-height: 115%; font-family: arial,helvetica,sans-serif; font-size: small; mso-fareast-font-family: PMingLiU; mso-fareast-theme-font: minor-fareast; mso-ansi-language: EN-US; mso-fareast-language: ZH-TW; mso-bidi-language: AR-SA;">Let me explain what is going on in this class.&nbsp; The main method in this class is FillAsync.&nbsp; FillAsync creates a background thread to add items into the expander view on the UI thread by using the BeginInvoke method on the Dispatcher.&nbsp; &nbsp;After an item is added through this method, we call a separate method called WaitForUI.&nbsp; WaitForUI is a slick way to verify that the UI has completed adding the previously added item and gives the UI a chance to respond to user input, typically scrolling.&nbsp; The AsyncObservableCollection object creates an AutoResetEvent that is triggered once the UI has freed up.&nbsp; To trigger this event, we need to get the UI to set the event when it is free.&nbsp; To do this, we queue up a call to UIFree through the BeginInvoke method on the Dispatcher as well.&nbsp;&nbsp; A picture may help:</span></p>
<p><span style="line-height: 115%; font-family: Consolas; font-size: 8pt; mso-fareast-font-family: PMingLiU; mso-fareast-theme-font: minor-fareast; mso-ansi-language: EN-US; mso-fareast-language: ZH-TW; mso-bidi-language: AR-SA;"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/41/44/7080.image%202.PNG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-41-44/7080.image-2.PNG"><img border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/41/44/7080.image%202.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-41-44/7080.image-2.PNG" /></a></span></p>
<p></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;" size="3"><span face="Calibri">The background thread dispatches the Add method followed by a dispatch to FreeUI method and then waits for the event to trigger.&nbsp; The UI thread receives the add call, completes it, calls UIFree which in turn sets the event.&nbsp; This triggers the event and the background thread ends blocking in the WaitAny call, sleeps for 10ms and then continues through the main loop to add the next item.&nbsp; This process repeats until all the items are finally added through the background thread.&nbsp; We give ourselves a 10ms sleep in the background thread to help the UI be a little more responsive.</span></span></p>
<p><span style="line-height: 115%; font-family: arial,helvetica,sans-serif; font-size: small; mso-fareast-font-family: PMingLiU; mso-fareast-theme-font: minor-fareast; mso-ansi-language: EN-US; mso-fareast-language: ZH-TW; mso-bidi-language: AR-SA;">Now to hook this all up, you need to change the InboxObject so that it derives from AsyncObservableCollection.&nbsp; Then create a new List object called conversations of type ConversationObject and instead of adding the new ConversationObjects to the base of the ObservableCollection through the add method, add the object to this new list object.&nbsp; Once all of the conversations are completed, you can then call FillAsync with your List object and allow the items to be added to the UI in the background.&nbsp; The result is that we immediately begin to see the items populate on the device and we are allowed to start scrolling with just a little stuttering.&nbsp; This is a much better result than waiting 10+ seconds before anything is displayed on the device.&nbsp; The new code for the InboxObject is shown below.</span></p>
<p></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas; color: green;">// (c) Copyright Microsoft Corporation.</span><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas; color: green;">// This source is subject to the Microsoft Public License (Ms-PL).</span><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas; color: green;">// Please see https://go.microsoft.com/fwlink/?LinkID=131993 for details.</span><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas; color: green;">// All other rights reserved.</span><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><o:p>&nbsp;</o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas; color: blue;">using</span><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"> System.Collections.ObjectModel;<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas; color: blue;">using</span><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"> System.Collections.Generic;<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><o:p>&nbsp;</o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas; color: blue;">namespace</span><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"> PhoneToolkitSample.Data<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;">{<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">InboxObject</span> : <span style="color: #2b91af;"> AsyncObservableCollection</span>&lt;<span style="color: #2b91af;">ConversationObject</span>&gt;<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">public</span> InboxObject() : <span style="color: blue;">base</span>()<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #2b91af;">List</span>&lt;<span style="color: #2b91af;">ConversationObject</span>&gt; conversations = <span style="color: blue;">new</span> <span style="color: #2b91af;"> List</span>&lt;<span style="color: #2b91af;">ConversationObject</span>&gt;();<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><o:p>&nbsp;</o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">for</span> (<span style="color: blue;">int</span> i = 0; i &lt; 20; i++)<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #2b91af;">ConversationObject</span> one = <span style="color: blue;">new</span> <span style="color: #2b91af;"> ConversationObject</span>(<span style="color: #a31515;">"3 messages, 0 unread"</span>);<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>one.Add(<span style="color: blue;">new</span> <span style="color: #2b91af;">EmailObject</span>(<span style="color: #a31515;">"Anne Wallace"</span>, <span style="color: #a31515;"> "Lunch Today?"</span>, <span style="color: #a31515;">"Sure!"</span>));<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>one.Add(<span style="color: blue;">new</span> <span style="color: #2b91af;">EmailObject</span>(<span style="color: #a31515;">"Me"</span>, <span style="color: #a31515;">"Lunch Today?"</span>, <span style="color: #a31515;">"OK, ask Dave?"</span>));<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>one.Add(<span style="color: blue;">new</span> <span style="color: #2b91af;">EmailObject</span>(<span style="color: #a31515;">"Bruno Denuit"</span>, <span style="color: #a31515;"> "Lunch Today?"</span>, <span style="color: #a31515;">"I vote for Thai."</span>));<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><o:p>&nbsp;</o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #2b91af;">ConversationObject</span> two = <span style="color: blue;">new</span> <span style="color: #2b91af;"> ConversationObject</span>(<span style="color: #a31515;">"1 messages, 0 unread"</span>);<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>two.Add(<span style="color: blue;">new</span> <span style="color: #2b91af;">EmailObject</span>(<span style="color: #a31515;">"Adriana Giorgi"</span>, <span style="color: #a31515;"> "Fun trip?"</span>, <span style="color: #a31515;">"Lucky you ..."</span>));<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><o:p>&nbsp;</o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #2b91af;">ConversationObject</span> three = <span style="color: blue;">new</span> <span style="color: #2b91af;"> ConversationObject</span>(<span style="color: #a31515;">"4 messages, 1 unread"</span>);<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>three.Add(<span style="color: blue;">new</span> <span style="color: #2b91af;"> EmailObject</span>(<span style="color: #a31515;">"Belinda Newman"</span>, <span style="color: #a31515;">"hawaii pics!"</span>, <span style="color: #a31515;"> "Good times."</span>));<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>three.Add(<span style="color: blue;">new</span> <span style="color: #2b91af;"> EmailObject</span>(<span style="color: #a31515;">"Richard Carey"</span>, <span style="color: #a31515;">"hawaii pics!"</span>, <span style="color: #a31515;">"Cool fish."</span>));<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>three.Add(<span style="color: blue;">new</span> <span style="color: #2b91af;"> EmailObject</span>(<span style="color: #a31515;">"C&lt;shorten&gt;r"</span>, <span style="color: #a31515;">"h pics!"</span>, <span style="color: #a31515;"> "Can't wait to get back."</span>));<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>three.Add(<span style="color: blue;">new</span> <span style="color: #2b91af;"> EmailObject</span>(<span style="color: #a31515;">"Melissa Kerr"</span>, <span style="color: #a31515;">"hawaii pics!"</span>, <span style="color: #a31515;"> "Check it and tag"</span>));<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><o:p>&nbsp;</o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>conversations.Add(one);<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>conversations.Add(two);<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>conversations.Add(three);<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><o:p>&nbsp;</o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: green;">// Fill the UI in the background</span><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">this</span>.FillAsync(conversations);<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>}<o:p></o:p></span></p>
<p><span style="font-size: 8.0pt; mso-bidi-font-size: 9.5pt; line-height: 115%; font-family: Consolas; mso-fareast-font-family: PMingLiU; mso-fareast-theme-font: minor-fareast; mso-ansi-language: EN-US; mso-fareast-language: ZH-TW; mso-bidi-language: AR-SA;">}</span></p>
<p></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;" size="3"><span face="Calibri">There is one major drawback with this code as it is presented; you end up making a copy of each of the items before it is presented to the UI thread.&nbsp; For simplicity in demonstrating this technique, I&rsquo;ve left this drawback in the code.</span></span></p>
<p></p>]]></content:encoded>
    </item>
    <item>
      <title>FIX - Delete your Builds or suffer the OOM Exception!</title>
      <link>https://docs.microsoft.com/archive/blogs/paulking/fix-delete-your-builds-or-suffer-the-oom-exception</link>
      <pubDate>Thu, 23 Feb 2012 07:44:49 GMT</pubDate>
      <dc:creator><![CDATA[Paul King - msft]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/paulking/2012/02/23/fix-delete-your-builds-or-suffer-the-oom-exception/</guid>
      <description><![CDATA[Last year I had a BLOG entry that talked about an issue where an Out of Memory Exception would occur...]]></description>
      <content:encoded><![CDATA[<p>Last year I had a <a title="BLOG entry" href="https://blogs.msdn.com/b/paulking/archive/2011/02/01/delete-your-builds-or-suffer-the-oom-exception.aspx">BLOG entry</a> that talked about an issue where an Out of Memory Exception would occur if you did not delete your completed builds from TFS.&nbsp; I'm happy to announce that there is a fix available for this issue in <a href="https://blogs.msdn.com/controlpanel/blogs/posteditor.aspx/<a title=&quot;KB2544407 here &quot; href=&quot;http:/support.microsoft.com/kb/2544407&quot;>KB2544407 here</a>:&amp;nbsp;">KB2544407 here:</a>&nbsp;</p>
<p><a href="https://support.microsoft.com/kb/2544407">https://support.microsoft.com/kb/2544407</a></p>]]></content:encoded>
    </item>
    <item>
      <title>How to modify the MachineQuota for MSMQ in Domain Mode through code</title>
      <link>https://docs.microsoft.com/archive/blogs/paulking/how-to-modify-the-machinequota-for-msmq-in-domain-mode-through-code</link>
      <pubDate>Mon, 16 Jan 2012 10:57:00 GMT</pubDate>
      <dc:creator><![CDATA[Paul King - msft]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/paulking/2012/01/16/how-to-modify-the-machinequota-for-msmq-in-domain-mode-through-code/</guid>
      <description><![CDATA[Our support website does a pretty good job for telling you how you can modify the MachineQuota...]]></description>
      <content:encoded><![CDATA[<p>Our support website does a pretty good job for telling you how you can modify the MachineQuota setting for MSMQ <a title="here." href="https://support.microsoft.com/kb/899612">here</a>.&nbsp; Unfortunately, if you need a way to do this programmatically and your installation happens to be in "Domain Mode", then there really isn't enough information here.&nbsp; Fortunately using the DirectoryEntry object makes this a pretty easy task.</p>
<p>The directory object for MSMQ (called msmq) is contained in Active Directory when in domain mode.&nbsp; That object is located at the LDAP path derived from the algorithm below:</p>
<p><span style="font-family: courier new,courier;">&lt;fqdn&gt;/X/&lt;machine name&gt;/msmq</span></p>
<p>Where X is evaluated as:</p>
<p><span style="font-family: courier new,courier;">if &lt;machine name&gt; is a domain controller then</span></p>
<p><span style="font-family: courier new,courier;">&nbsp;&nbsp; x = "Domain Controllers"</span></p>
<p><span style="font-family: courier new,courier;">else</span></p>
<p><span style="font-family: courier new,courier;">&nbsp;&nbsp;&nbsp;x = "Computers"</span></p>
<p>&nbsp;In my case, I had a domain named &ldquo;PKMSMQ.PKING.COM&rdquo;.&nbsp; My domain controller was the computer &ldquo;MSMQ-AD&rdquo;, and that was the machine I installed MSMQ on.&nbsp; Realize that is not recommended to install MSMQ on the domain controller, but I took a short cut here instead.&nbsp; My complete LDAP object path in this case is:</p>
<p><span style="color: #3366ff;"><span style="color: #3366ff;">LDAP://CN=msmq,CN=MSMQ-AD,OU=Domain</span> Controllers,DC=PKMSMQ,DC=PKING,DC=COM</span></p>
<p>If I had been working on a server within that domain, My LDAP object path would have looked like this:</p>
<p><span style="color: #3366ff;"><span style="color: #3366ff;">LDAP://CN=msmq,CN=MSMQSERVER,CN=Computer</span>s,DC=PKMSMQ,DC=PKING,DC=COM</span></p>
<p>Notice the difference here.&nbsp; 'Domain Controllers' is an organizational unit and 'Computers' is just a container.&nbsp; I missed that difference in my original post.</p>
<p>Some simple code to adjust the value is shown below:</p>
<p><span style="font-size: 9.5pt; font-family: Consolas; color: green;">// Get the object and the value</span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: #2b91af;">DirectoryEntry</span><span style="font-size: 9.5pt; font-family: Consolas;"> de = <span style="color: blue;"> new</span> <span style="color: #2b91af;">DirectoryEntry</span>(&lt;YOUR LDAP PATH&gt;);<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;">int</span><span style="font-size: 9.5pt; font-family: Consolas;"> value = (<span style="color: blue;">int</span>) de.Properties[<span style="color: #a31515;">"mSMQQuota"</span>].Value;<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><o:p>&nbsp;</o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: green;">// Remove one from the value and set it</span><span style="font-size: 9.5pt; font-family: Consolas;"><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">value--;<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">de.Properties[<span style="color: #a31515;">"mSMQQuota"</span>].Value = value;<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">de.CommitChanges();<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><o:p>&nbsp;</o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: green;">// Close the directory entry</span><span style="font-size: 9.5pt; font-family: Consolas;"><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">de.Close();</span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"></span>&nbsp;</p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-family: arial,helvetica,sans-serif; font-size: 9.5pt;">Hope this helps someone!</span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-family: arial,helvetica,sans-serif; font-size: 9.5pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><strong>&lt;UPDATED - Feb 9. 2012&gt;</strong></p>
<p></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal">Some additional details on this solution were discovered after I published this article.&nbsp; In some cases (Windows 7 machines), mSMQQuota is not set.&nbsp; Instead a default value is used and this code:</p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><br />&nbsp;<span style="font-family: Consolas; font-size: 9.5pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">int</span><span style="font-family: Consolas; font-size: 9.5pt;"> value = (<span style="color: blue;">int</span>) de.Properties[<span style="color: #a31515;">"mSMQQuota"</span>].Value;<o:p></o:p></span></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"></span>&nbsp;</p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal">will cause an exception to be thrown.&nbsp; To set the value int this case, you can avoid the exception by not checking the value first and just setting it.&nbsp; The default value is 1048576 KB and setting&nbsp;the value is as&nbsp;easy as:</p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal">&nbsp;</p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;">de.Properties[<span style="color: #a31515;">"mSMQQuota"</span>].Value = 1048576;</span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;">de.CommitChanges();</span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"></span>&nbsp;</p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal">A better&nbsp;code sample&nbsp;in this case&nbsp;is shown&nbsp;below:</p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal">&nbsp;</p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal">&nbsp;</p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: green;">// Get the object and the value</span><span style="font-size: 9.5pt; font-family: Consolas;"><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: #2b91af;">DirectoryEntry</span><span style="font-size: 9.5pt; font-family: Consolas;"> de = <span style="color: blue;"> new</span> <span style="color: #2b91af;">DirectoryEntry</span>(lblObjName.Text);<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><o:p>&nbsp;</o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;">bool</span><span style="font-size: 9.5pt; font-family: Consolas;"> result = <span style="color: blue;">false</span>;<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><o:p>&nbsp;</o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;">try</span><span style="font-size: 9.5pt; font-family: Consolas;"><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">{<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span> result = de.Properties.Contains(<span style="color: #a31515;">"mSMQQuota"</span>);<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">}<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;">catch</span><span style="font-size: 9.5pt; font-family: Consolas;"> (<span style="color: #2b91af;">Exception</span> ex)<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">{<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span> <span style="color: green;">// If we throw an exception here, MSMQ may not be installed in AD mode</span><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span> <span style="color: #2b91af;">MessageBox</span>.Show(<span style="color: blue;">this</span>, <span style="color: blue;">string</span>.Format(<span style="color: #a31515;">"{0}{1}{2}"</span>, <o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #a31515;">"The msmq configuration object was not found.<span style="mso-spacerun: yes;">&nbsp; </span>"</span>, <o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #a31515;">"MSMQ may not be installed in AD mode.\r\n\r\n"</span>,<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>ex.Message),<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #a31515;">"MSMQ Directory App"</span>, <span style="color: #2b91af;">MessageBoxButtons</span>.OK, <o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #2b91af;">MessageBoxIcon</span>.Exclamation);<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; &nbsp;</span>de.Close();<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; &nbsp;</span><span style="color: blue;">return</span>;<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">}<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><o:p>&nbsp;</o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;">if</span><span style="font-size: 9.5pt; font-family: Consolas;"> (!result)<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">{<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span> <span style="color: green;">// Property is not set yet</span><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span> <span style="color: #2b91af;">DialogResult</span> dr = <span style="color: #2b91af;"> MessageBox</span>.Show(<span style="color: blue;">this</span>, <span style="color: blue;">string</span>.Format(<span style="color: #a31515;">"{0}{1}"</span>, <o:p></o:p> </span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #a31515;">"mSMQQuota is not found.<span style="mso-spacerun: yes;">&nbsp; </span>Property is not set yet.<span style="mso-spacerun: yes;">&nbsp; </span>"</span>, <o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #a31515;">"Do you wish to set it to the default value of 1048576 KB?"</span>), <o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #a31515;">"MSMQ Directory App"</span>, <span style="color: #2b91af;">MessageBoxButtons</span>.YesNo, <o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #2b91af;">MessageBoxIcon</span>.Question);<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><o:p>&nbsp;</o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span> <span style="color: blue;">if</span> (<span style="color: #2b91af;">DialogResult</span>.Yes == dr)<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>de.Properties[<span style="color: #a31515;">"mSMQQuota"</span>].Value = 1048576;<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>de.CommitChanges();<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>}<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">}<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;">else</span><span style="font-size: 9.5pt; font-family: Consolas;"><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">{<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span> <span style="color: blue;">int</span> value = (<span style="color: blue;">int</span>)de.Properties[<span style="color: #a31515;">"mSMQQuota"</span>].Value;<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><o:p>&nbsp;</o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span> <span style="color: green;">// Remove one from the value and set it</span><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span> value--;<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span> de.Properties[<span style="color: #a31515;">"mSMQQuota"</span>].Value = value;<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span> de.CommitChanges();<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><o:p>&nbsp;</o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span> <span style="color: #2b91af;">MessageBox</span>.Show(<span style="color: blue;">this</span>, <span style="color: blue;">string</span>.Format(<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #a31515;">"mSMQQuota changed to {0} on object: {1}"</span>, <o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>value, lblObjName.Text), <span style="color: #a31515;">"MSMQ Directory App"</span>, <o:p></o:p> </span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #2b91af;">MessageBoxButtons</span>.OK, <o:p></o:p> </span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #2b91af;">MessageBoxIcon</span>.Information);<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">}<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><o:p>&nbsp;</o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: green;">// Close the directory entry</span><span style="font-size: 9.5pt; font-family: Consolas;"><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">de.Close();</span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"></span>&nbsp;</p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal">This covers the problem of MSMQ not being installed and setting the quota value when once does not already exist.&nbsp; An additional issue is when the schema for your directory includes other organizational units.&nbsp; When this happens, the simplistic naming rules shown here do not find the correct computer objects.&nbsp; A better solution is to search for the computer in the directory.&nbsp; This can be done by using the DirectorySearcher class in the .Net Framework.&nbsp; A code sample to find the correct path to a computer within the domain can be found below.</p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal">&nbsp;</p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal">&nbsp;<span style="font-size: 9.5pt; font-family: Consolas; color: green;">// Find the domain we are working in</span><span style="font-size: 9.5pt; font-family: Consolas;"><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: #2b91af;">DirectoryEntry</span><span style="font-size: 9.5pt; font-family: Consolas;"> de = <span style="color: blue;"> new</span> <span style="color: #2b91af;">DirectoryEntry</span>(<span style="color: #a31515;">"LDAP://rootDSE"</span>);<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;">string</span><span style="font-size: 9.5pt; font-family: Consolas;"> root = de.Properties[<span style="color: #a31515;">"defaultNamingContext"</span>].Value.ToString();<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">de.Close();<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><o:p>&nbsp;</o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: green;">// Query the domain for all the machines in the domain</span><span style="font-size: 9.5pt; font-family: Consolas;"><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">de = <span style="color: blue;">new</span> <span style="color: #2b91af;">DirectoryEntry</span>(<span style="color: #a31515;">"LDAP://"</span> + root);<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: #2b91af;">DirectorySearcher</span><span style="font-size: 9.5pt; font-family: Consolas;"> ds = <span style="color: blue;"> new</span> <span style="color: #2b91af;">DirectorySearcher</span>(de,<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; text-indent: 21.0pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;">string</span><span style="font-size: 9.5pt; font-family: Consolas;">.Format(<span style="color: #a31515;">"(&amp;(objectCategory=computer)(CN={0}))"</span>,<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span> txtFindComputer.Text));<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><o:p>&nbsp;</o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: #2b91af;">SearchResultCollection</span><span style="font-size: 9.5pt; font-family: Consolas;"> coll = ds.FindAll();<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><o:p>&nbsp;</o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: green;">// Validate there is only one item in the collection</span><span style="font-size: 9.5pt; font-family: Consolas;"><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><o:p>&nbsp;</o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;">if</span><span style="font-size: 9.5pt; font-family: Consolas;"> (coll.Count &gt; 1)<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">{<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span> <span style="color: green;">// If more than one machine is found, abort processing.</span><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span> <span style="color: green;">// You could display a list of the machines found </span><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span> <span style="color: green;">// and let the user pick which one to adjust</span><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span> <span style="color: #2b91af;">MessageBox</span>.Show(<span style="color: blue;">this</span>, <span style="color: blue;">string</span>.Format(<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #a31515;">"{0} computers matched the computer name.<span style="mso-spacerun: yes;">&nbsp; </span>Processing Aborted."</span>, <o:p></o:p> </span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;</span>coll.Count), <span style="color: #a31515;">"MSMQ Directory App"</span>,<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #2b91af;">MessageBoxButtons</span>.OK,<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #2b91af;">MessageBoxIcon</span>.Exclamation);<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">}<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;">else</span><span style="font-size: 9.5pt; font-family: Consolas;"> <span style="color: blue;">if</span> (coll.Count == 1)<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">{<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span> <span style="color: green;">// One computer found, populate our LDAP Object Path</span><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span> <span style="color: #2b91af;">DirectoryEntry</span> targetComputer = coll[0].GetDirectoryEntry();<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;</span>lblObjName.Text = targetComputer.Path.Insert(7, <span style="color: #a31515;">"CN=msmq,"</span>);<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><o:p>&nbsp;</o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span> targetComputer.Close();<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><o:p>&nbsp;</o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span> <span style="color: #2b91af;">MessageBox</span>.Show(<span style="color: blue;">this</span>, <span style="color: blue;">string</span>.Format(<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>"Computer {0} found.<span style="mso-spacerun: yes;">&nbsp; </span>LDAP Object Path updated."</span><span style="font-size: 9.5pt; font-family: Consolas;">, <o:p></o:p> </span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>txtFindComputer.Text), <span style="color: #a31515;">"MSMQ Directory App"</span>,<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #2b91af;">MessageBoxButtons</span>.OK,<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #2b91af;">MessageBoxIcon</span>.Information);<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">}<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;">else</span><span style="font-size: 9.5pt; font-family: Consolas;"><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">{<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span> <span style="color: green;">// No computers found matching that name</span><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: #2b91af;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>MessageBox</span><span style="font-size: 9.5pt; font-family: Consolas;">.Show(<span style="color: blue;">this</span>, <span style="color: blue;">string</span>.Format(<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #a31515;">"No computers matched the computer name {0}.<span style="mso-spacerun: yes;">&nbsp; </span>Processing Aborted."</span>, <o:p></o:p> </span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;</span>txtFindComputer.Text), <o:p></o:p> </span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #a31515;">"MSMQ Directory App"</span>,<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #2b91af;">MessageBoxButtons</span>.OK,<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #2b91af;">MessageBoxIcon</span>.Information);<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">}<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><o:p>&nbsp;</o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">de.Close();<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal">&nbsp;&nbsp;</p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal">I have updated&nbsp;the code sample below&nbsp;to include these updates as well.&nbsp; Enjoy!</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/10/25/72/22/MSMQ%20Directory%20App.zip" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-10-25-72-22/MSMQ-Directory-App.zip">MSMQ Directory App.zip</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Using an HTTP Module to assist in adjusting the value of aspnet:MaxHttpCollectionKeys imposed by MS11-100</title>
      <link>https://docs.microsoft.com/archive/blogs/paulking/using-an-http-module-to-assist-in-adjusting-the-value-of-aspnetmaxhttpcollectionkeys-imposed-by-ms11-100</link>
      <pubDate>Mon, 16 Jan 2012 05:05:00 GMT</pubDate>
      <dc:creator><![CDATA[Paul King - msft]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/paulking/2012/01/16/using-an-http-module-to-assist-in-adjusting-the-value-of-aspnetmaxhttpcollectionkeys-imposed-by-ms11-100/</guid>
      <description><![CDATA[Internet applications using ASP.Net recently had an update (MS11-100) pushed out of band back in...]]></description>
      <content:encoded><![CDATA[<p>Internet applications using ASP.Net recently had an update (<a title="MS11-100" href="https://support.microsoft.com/kb/2661403">MS11-100</a>) pushed out of band back in December that set a limit of 1000 items to be accepted by a web form.&nbsp; While this is not the only limit imposed, it is the one that&nbsp;some applications are hitting.&nbsp;&nbsp;If you exceed this value, an exception is thrown that looks like the one below:</p>
<p><span style="font-family: courier new,courier; font-size: xx-small;">System.Web.HttpException:</span><br /><span style="font-family: courier new,courier; font-size: xx-small;">The URL-encoded form data is not valid. ---&gt; System.InvalidOperationException: Operation is not valid due to the current state of the object.</span><br /><span style="font-family: courier new,courier; font-size: xx-small;">&nbsp;&nbsp; at System.Web.HttpValueCollection.<strong>ThrowIfMaxHttpCollectionKeysExceeded</strong>()</span><br /><span style="font-family: courier new,courier; font-size: xx-small;">&nbsp;&nbsp; at System.Web.HttpValueCollection.FillFromEncodedBytes(Byte[] bytes, Encoding encoding)</span><br /><span style="font-family: courier new,courier; font-size: xx-small;">&nbsp;&nbsp; at System.Web.HttpRequest.FillInFormCollection()</span><br /><span style="font-family: courier new,courier; font-size: xx-small;">&nbsp;&nbsp; --- End of inner exception stack trace ---</span><br /><span style="font-family: courier new,courier; font-size: xx-small;">&nbsp;&nbsp; at System.Web.HttpRequest.FillInFormCollection()</span><br /><span style="font-family: courier new,courier; font-size: xx-small;">&nbsp;&nbsp; at System.Web.HttpRequest.get_Form()</span></p>
<p>The key here is ThrowIfMaxHttpCollectionKeysExceeded.&nbsp; If that is in your stack trace, you know that you have exceeded the value the patch imposes.</p>
<p>To keep this exception from being thrown, you need to change the value of aspnet:MaxHttpCollectionKeys in the web.config of your application to a value that is as high as the highest allowed count of keys in your hash table.&nbsp;</p>
<p>To help you figure out what value you should use in production, I have created a HTTP Module that counts the number of keys in that collection for each request and stores the high water mark in the event log once the module is unloaded.&nbsp; I have included a sample that shows how this works.</p>
<p>For you to test this in your application, you need to build the MS11-1000Helper.DLL and place it in your web application&rsquo;s Bin directory.&nbsp; Once you have done this, you need to add the following to your web.config file to enable the HTTP Module:</p>
<p style="text-autospace: none;" class="MsoNormal"><span style="font-size: xx-small;"><span style="color: blue; font-family: Consolas;">&lt;</span><span style="color: #a31515; font-family: Consolas;">system.web</span><span style="color: blue; font-family: Consolas;">&gt;</span><span style="font-family: Consolas;"><o:p></o:p></span></span></p>
<p style="text-autospace: none;" class="MsoNormal"><span style="font-size: xx-small;"><span style="color: blue; font-family: Consolas;">&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: #a31515; font-family: Consolas;">httpModules</span><span style="color: blue; font-family: Consolas;">&gt; </span> <span style="font-family: Consolas;"><o:p></o:p></span></span></p>
<p style="text-autospace: none;" class="MsoNormal"><span style="font-size: xx-small;"><span style="color: blue; font-family: Consolas;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;</span><span style="color: #a31515; font-family: Consolas;">add</span><span style="color: blue; font-family: Consolas;"> </span> <span style="color: red; font-family: Consolas;">type</span><span style="color: blue; font-family: Consolas;">=</span><span style="font-family: Consolas;">"<span style="color: blue;">MS11_100_Helper.CounterModule, MS11-100-Helper</span>"<span style="color: blue;"> </span><span style="color: red;"> name</span><span style="color: blue;">=</span>"<span style="color: blue;">CounterModule</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></span></p>
<p style="text-autospace: none;" class="MsoNormal"><span style="font-size: xx-small;"><span style="color: blue; font-family: Consolas;">&nbsp;&nbsp;&nbsp; &lt;/</span><span style="color: #a31515; font-family: Consolas;">httpModules</span><span style="color: blue; font-family: Consolas;">&gt;<o:p></o:p></span></span></p>
<p style="text-autospace: none;" class="MsoNormal"><span style="font-size: xx-small;"><span style="color: blue; font-family: Consolas;">&lt;/</span><span style="color: #a31515; font-family: Consolas;">system.web</span><span style="color: blue; font-family: Consolas;">&gt;</span></span><span style="font-size: 9.5pt; font-family: Consolas;"><o:p></o:p></span></p>
<p>&nbsp;</p>
<p>Additionally, you need to add the following to your appSettings:</p>
<p class="MsoNormal"><span style="font-size: xx-small;"><span style="color: blue; font-family: Consolas;">&lt;</span><span style="color: #a31515; font-family: Consolas;">appSettings</span><span style="color: blue; font-family: Consolas;">&gt;</span><span style="font-family: Consolas;"><o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-size: xx-small;"><span style="color: blue; font-family: Consolas;">&nbsp;&nbsp;&nbsp; &lt;!--</span><span style="font-family: Consolas;"><o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="color: green; font-family: Consolas; font-size: xx-small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; This is a super high number to use as a starting point in TESTING your application.&nbsp; <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: xx-small;"><span style="color: green; font-family: Consolas;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;You should never have a number like this in your PRODUCTION web.confg.</span><span style="font-family: Consolas;"><o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="color: green; font-family: Consolas; font-size: xx-small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Instead, you should use this HTTP module (MS11-100-Helper.dll) to help you determine <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: xx-small;"><span style="color: green; font-family: Consolas;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;the appropriate number to use for your setting in PRODUCTION.</span><span style="font-family: Consolas;"><o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-size: xx-small;"><span style="color: green; font-family: Consolas;">&nbsp;&nbsp;&nbsp; </span> <span style="color: blue; font-family: Consolas;">--&gt;</span><span style="font-family: Consolas;"><o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-size: xx-small;"><span style="color: blue; font-family: Consolas;">&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: #a31515; font-family: Consolas;">add</span><span style="color: blue; font-family: Consolas;"> </span> <span style="color: red; font-family: Consolas;">key</span><span style="color: blue; font-family: Consolas;">=</span><span style="font-family: Consolas;">"<span style="color: blue;">aspnet:MaxHttpCollectionKeys</span>"<span style="color: blue;"> </span><span style="color: red;">value</span><span style="color: blue;">=</span>"<span style="color: blue;">9999</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-size: xx-small;"><span style="color: blue; font-family: Consolas;">&lt;/</span><span style="color: #a31515; font-family: Consolas;">appSettings</span></span><span style="font-size: 9.5pt; font-family: Consolas; color: blue;"><span style="font-size: xx-small;">&gt;</span><o:p></o:p></span></p>
<p>&nbsp;</p>
<p>Then you should <strong>TEST</strong> your application.&nbsp; If you are dynamically generating Forms items in your application, you need to test with the highest amount of generated UI as you expect to ever see while your application is being run.&nbsp;</p>
<p>After you have tested the above scenario, you need to close the browser and terminate the web server (stop the development server or issue an IISRESET).&nbsp; Once you have done this, the high water mark should be written to the event log &ldquo;Applications and Services Logs/CounterSourceLog&rdquo; and you should have an Information entry that looks like this:</p>
<p>Largest Value Seen = X</p>
<p>Where X is some number.&nbsp;</p>
<p>You can then use this number to help you set the value of aspnet:MaxHttpCollectionKeys in production.&nbsp;</p>
<p>I would personally set the number to be a little higher than the value here, but that depends on the application.&nbsp; If you don&rsquo;t have a lot of dynamically generated forms controls, then the number is probably pretty close to what you can use for your deployed application.&nbsp; You might want to add just a few more to the value just in case you have a last minute tweak that puts you over the limit.</p>
<p>If you have pages that can dynamically generate a ton of controls without limit (indicating a bad design), then this isn't going to help you much.</p>
<p><span style="font-size: small;"><b>Just be sure to remove the module and 9999 limit from your production code!!!&nbsp; </b></span></p>
<p>There are a couple of additional caveats with this as far as being the end all to this issue.&nbsp;</p>
<p>First, realize that MS11-100 is a workaround to help limit a DOS attack.&nbsp; The final fix will be to randomize the hash tables used in the ASP.Net will be in a change that comes later.&nbsp; Once that change is available, this workaround may not be needed.</p>
<p>Second, this helper only counts the keys in the Form collection.&nbsp; If you are running into an issue where you are seeing an exception thrown for Json, then this code will not help you.</p>
<p>Third, if the high water mark is less than 1000, I wouldn't recommend changing the default app setting of aspnet:MMaxHttpCollectionKeys.&nbsp; A DOS attacker will probably be hitting numbers much higher than this to cause the issue to occur, which is why we choose the number to begin with.</p>
<p>Fourth, anytime you make an application change, you should reuse this tool in <strong>TEST</strong> to help you figure out the value of the setting in production.</p>
<p>Special thanks to <span id="name" class="n fn"><span class="full-name"><span class="given-name">Wyn</span> <span class="family-name">Lewis-Bevan</span></span> for the idea&nbsp;on developing this helper!</span></p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/10/25/70/97/MS11-100-Helper.zip" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-10-25-70-97/MS11_2D00_100_2D00_Helper.zip">MS11-100-Helper.zip</a></p>]]></content:encoded>
    </item>
    <item>
      <title>How many times do I have to tell you, the right tool for the right job!</title>
      <link>https://docs.microsoft.com/archive/blogs/paulking/how-many-times-do-i-have-to-tell-you-the-right-tool-for-the-right-job</link>
      <pubDate>Wed, 21 Dec 2011 10:54:00 GMT</pubDate>
      <dc:creator><![CDATA[Paul King - msft]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/paulking/2011/12/21/how-many-times-do-i-have-to-tell-you-the-right-tool-for-the-right-job/</guid>
      <description><![CDATA[How many times have you used one tool for a job only to have the requirements change and you then...]]></description>
      <content:encoded><![CDATA[<p>How many times have you used one tool for a job only to have the requirements change and you then realize the tool doesn't support the new requirements?&nbsp; It happens very often!&nbsp; Let's consider this requirement for a WinForms application:</p>
<p><strong>REQUIREMENT</strong>: On any error, display the error message as richly formatted text and allow for URLs to take the user to additional assistance.</p>
<p>No problem, there is a RichTextBox control in .Net that will do this for you.&nbsp; You make up all the text as RTF, load it at run-time as needed, follow the guidance on <a title="MSDN here" href="https://msdn.microsoft.com/en-us/library/f591a55w.aspx">MSDN here</a> for linking to the web and you have a nifty dialog that will satisfy the above requirement in a very short period of time.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/41/44/8244.Capture1.PNG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-41-44/8244.Capture1.PNG"><img border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/41/44/8244.Capture1.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-41-44/8244.Capture1.PNG" /></a></p>
<p>You then receive some additional information about the requirement:</p>
<p><strong>REQUIREMENT</strong>: On any error, display the error message as richly formatted text and allow for arbitrary text to act as a&nbsp;hyperlink to take the user to additional assistance.</p>
<p>No problem - you just modify your RFT to create the hyperlinks and you're all set.&nbsp; Then you see the result:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/41/44/2350.Capture2.PNG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-41-44/2350.Capture2.PNG"><img border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/41/44/2350.Capture2.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-41-44/2350.Capture2.PNG" /></a></p>
<p>Wait a minute.&nbsp; That's not what's in my RTF file.&nbsp; You specified this:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/41/44/2705.Capture3.PNG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-41-44/2705.Capture3.PNG"><img border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/41/44/2705.Capture3.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-41-44/2705.Capture3.PNG" /></a></p>
<p>Unfortunately the RichTextBox control doesn't handle the anchor tag the way you can if you were authoring this as HTML.&nbsp; So, what are you supposed to do?&nbsp; There are some solutions on the web, for modifying the RichTextBox control, but you want to avoid licensing issues.&nbsp; This is where I see Scotty from Star Trek saying, 'How many times do I have to tell you, the right tool for the right job!'.&nbsp; If you need links to look like they would on a web page, then create a&nbsp;WebBrowser control&nbsp;to display the text instead of the RichTextBox control!&nbsp; It couldn't be simpler.&nbsp; Sway out the controls and to handle the user clicking on the link generically, you only need to write a couple of lines of code.&nbsp;</p>
<p>In your form load method, add the event handler:</p>
<p><span style="font-size: x-small;">webBrowser1.Navigating +=</span>&nbsp;<span style="color: #0000ff; font-family: Consolas; font-size: x-small;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff; font-family: Consolas; font-size: x-small;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff; font-family: Consolas; font-size: x-small;" face="Consolas" size="2" color="#0000ff">new</span></span></span><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2"><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2"> </span></span><span style="color: #2b91af; font-family: Consolas; font-size: x-small;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af; font-family: Consolas; font-size: x-small;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af; font-family: Consolas; font-size: x-small;" face="Consolas" size="2" color="#2b91af">WebBrowserNavigatingEventHandler</span></span></span><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2"><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2">(webBrowser1_Navigating);</span></span></p>
<p>And your event handler should have this code:</p>
<p><span style="color: #0000ff; font-family: Consolas; font-size: x-small;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff; font-family: Consolas; font-size: x-small;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff; font-family: Consolas; font-size: x-small;" face="Consolas" size="2" color="#0000ff">private void</span></span></span><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2"><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2">&nbsp;webBrowser1_Navigating(</span></span><span style="color: #0000ff; font-family: Consolas; font-size: x-small;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff; font-family: Consolas; font-size: x-small;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff; font-family: Consolas; font-size: x-small;" face="Consolas" size="2" color="#0000ff">object</span></span></span><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2"><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2"> sender, </span></span><span style="color: #2b91af; font-family: Consolas; font-size: x-small;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af; font-family: Consolas; font-size: x-small;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af; font-family: Consolas; font-size: x-small;" face="Consolas" size="2" color="#2b91af">WebBrowserNavigatingEventArgs</span></span></span><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2"><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2"> e)</span></span></p>
<p>{</p>
<p><span style="color: #008000; font-family: Consolas; font-size: x-small;" face="Consolas" size="2" color="#008000"><span style="color: #008000; font-family: Consolas; font-size: x-small;" face="Consolas" size="2" color="#008000"><span style="color: #008000; font-family: Consolas; font-size: x-small;" face="Consolas" size="2" color="#008000">&nbsp;&nbsp; // Override the navigation property and just bring up a web browser</span></span></span></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; <span style="font-size: x-small;">System.Diagnostics.</span><span style="color: #2b91af; font-family: Consolas; font-size: x-small;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af; font-family: Consolas; font-size: x-small;" face="Consolas" size="2" color="#2b91af"><span style="color: #2b91af; font-family: Consolas; font-size: x-small;" face="Consolas" size="2" color="#2b91af">Process</span></span></span><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2"><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2">.Start(</span></span><span style="color: #a31515; font-family: Consolas; font-size: x-small;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515; font-family: Consolas; font-size: x-small;" face="Consolas" size="2" color="#a31515"><span style="color: #a31515; font-family: Consolas; font-size: x-small;" face="Consolas" size="2" color="#a31515">"IEXPLORE.EXE"</span></span></span><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2"><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2">, e.Url.ToString());</span></span></p>
<p><span style="color: #008000; font-family: Consolas; font-size: x-small;" face="Consolas" size="2" color="#008000"><span style="color: #008000; font-family: Consolas; font-size: x-small;" face="Consolas" size="2" color="#008000"><span style="color: #008000; font-family: Consolas; font-size: x-small;" face="Consolas" size="2" color="#008000">&nbsp;&nbsp; // Stop any navigation in our control</span></span></span></p>
<p><span style="font-size: x-small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; e.Cancel =</span> <span style="color: #0000ff; font-family: Consolas; font-size: x-small;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff; font-family: Consolas; font-size: x-small;" face="Consolas" size="2" color="#0000ff"><span style="color: #0000ff; font-family: Consolas; font-size: x-small;" face="Consolas" size="2" color="#0000ff">true</span></span></span><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2"><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2">;</span></span></p>
<p>}</p>
<p>Here is the final result.&nbsp; Looks nice doesn't it?</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/41/44/5050.Capture4.PNG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-41-44/5050.Capture4.PNG"><img border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/41/44/5050.Capture4.PNG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-41-44/5050.Capture4.PNG" /></a></p>
<p>&nbsp;</p>]]></content:encoded>
    </item>
  </channel>
</rss>