<?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>blambert's blog</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/blambert/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/blambert/feed.xml</link>
    <description>Developer blog of Brian Lambert</description>
    <lastBuildDate>Wed, 17 Apr 2019 03:18:56 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>DOCS.COM</title>
      <link>https://docs.microsoft.com/archive/blogs/blambert/docs-com</link>
      <pubDate>Fri, 23 Apr 2010 00:06:40 GMT</pubDate>
      <dc:creator><![CDATA[x11mnt]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/blambert/2010/04/23/docs-com/</guid>
      <description><![CDATA[For the last 4 months, Matt Augustine and myself, along with Raman Narayanan, Richard Speyer, and...]]></description>
      <content:encoded><![CDATA[<p>For the last 4 months, Matt Augustine and myself, along with Raman Narayanan, Richard Speyer, and Andrzej Turski, have been the main devs on <a href="https://docs.com">https://docs.com</a>.&nbsp; What an amazing project!</p> <p>My role in all of this was to bring up some very custom roles inside of Windows Azure.&nbsp; Stuff I can't really talk about now, but, will be able to blog about in the coming months.&nbsp; It wasn't the most glamorous role on this project, but for me, it was the beefiest, and the best fit.</p> <p>One thing I can share is that the Windows Azure team is the best.&nbsp; Microsoft, and our Windows Azure offering, lead by Amitabh Srivastava, is Cloud Computing for real.&nbsp; The cloud is a 1.0 product, on all fronts, and this platform is the future of computing.</p> <p>Ray Ozzie / Jack Ozzie / Lili Cheng (in no particular order), leading FUSE Labs, and our team of Ninja developers, PM's, designers, testers, and marketing folks, among which I am proud to be a member, really did some cool stuff with <a href="https://docs.com">https://docs.com</a>.&nbsp; I wish I could name the whole team, but, I'm sure I would leave someone out.&nbsp; You all know who you are.&nbsp; We all know.</p> <p>And a special shout out to Pat Kinsel, who played hard, and is a rainmaker.</p> <p>Best!</p> <p>Brian</p>]]></content:encoded>
    </item>
    <item>
      <title>HRESULT=D0000033 When calling CloudDrive.Mount</title>
      <link>https://docs.microsoft.com/archive/blogs/blambert/hresultd0000033-when-calling-clouddrive-mount</link>
      <pubDate>Thu, 11 Mar 2010 11:51:04 GMT</pubDate>
      <dc:creator><![CDATA[x11mnt]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/blambert/2010/03/11/hresultd0000033-when-calling-clouddrive-mount/</guid>
      <description><![CDATA[I’ve been working with Azure’s new CloudDrive capability, and today I ran into a problem with...]]></description>
      <content:encoded><![CDATA[<p>I’ve been working with Azure’s new CloudDrive capability, and today I ran into a problem with caching that I thought I would share the workaround for.</p>  <p>The first step in using caching with CloudDrive is to define a LocalResource for the role in the csdef file:</p>  <p>&#160;&#160;&#160; <span style="color: blue">&lt;</span><span style="color: #a31515">LocalResources</span><span style="color: blue">&gt;     <br />&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">LocalStorage </span><span style="color: red">name</span><span style="color: blue">=</span>&quot;<span style="color: blue">AzureDriveCache</span>&quot; <span style="color: red">cleanOnRoleRecycle</span><span style="color: blue">=</span>&quot;<span style="color: blue">false</span>&quot; <span style="color: red">sizeInMB</span><span style="color: blue">=</span>&quot;<span style="color: blue">8000</span>&quot; <span style="color: blue">/&gt;     <br />&#160;&#160;&#160; &lt;/</span><span style="color: #a31515">LocalResources</span><span style="color: blue">&gt;     <br /></span></p>  <p>Next, you need to initialize CloudDrive caching thus:</p>  <pre class="code"><span style="color: blue">var </span>localResource = <span style="color: #2b91af">RoleEnvironment</span>.GetLocalResource(<span style="color: #a31515">&quot;AzureDriveCache&quot;</span>);
<span style="color: #2b91af">CloudDrive</span>.InitializeCache(localResource.RootPath, localResource.MaximumSizeInMegabytes);</pre>

<p>And finally, mount your drive:</p>

<pre class="code"><span style="color: blue">var </span>driveLetter = cloudDrive.Mount(4000, <span style="color: #2b91af">DriveMountOptions</span>.None);</pre>

<p>And this is when the problem comes up.&#160; Doing this will result in an exception: HRESULT=D0000033 When calling CloudDrive.Mount</p>

<p>Through logging, I see that the RootPath property above was returned as:</p>

<p><strong>C:\Resources\directory\d15989a9895847ee9672b0f217f427bf.XWorkerRole.AzureDriveCache\</strong></p>

<p>After consulting with the Azure team, I learned that there is a bug in the current SDK, and that the trailing ‘\’ character is the cause of the error.</p>

<p>Remove it, and you’ll be fine.</p>]]></content:encoded>
    </item>
    <item>
      <title>Moving to Redmond!</title>
      <link>https://docs.microsoft.com/archive/blogs/blambert/moving-to-redmond</link>
      <pubDate>Tue, 09 Mar 2010 17:46:39 GMT</pubDate>
      <dc:creator><![CDATA[x11mnt]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/blambert/2010/03/09/moving-to-redmond/</guid>
      <description><![CDATA[Well, it’s official -- I am moving to Redmond to work for Microsoft.&#160; I’m very excited about...]]></description>
      <content:encoded><![CDATA[<p>Well, it’s official -- I am moving to Redmond to work for Microsoft.&#160; I’m very excited about the opportunity to be on the Mother Ship and work on cool stuff with my team here.</p>  <p>Best!</p>  <p>Brian</p>]]></content:encoded>
    </item>
    <item>
      <title>Entity Group Transactions and Development Storage</title>
      <link>https://docs.microsoft.com/archive/blogs/blambert/entity-group-transactions-and-development-storage</link>
      <pubDate>Wed, 06 Jan 2010 16:44:00 GMT</pubDate>
      <dc:creator><![CDATA[x11mnt]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/blambert/2010/01/06/entity-group-transactions-and-development-storage/</guid>
      <description><![CDATA[Have you gotten the error: InvalidInput One of the request inputs is not valid when performing an...]]></description>
      <content:encoded><![CDATA[<P>Have you gotten the error: <STRONG>InvalidInput One of the request inputs <SPAN class=kwrd>is</SPAN> not valid</STRONG> when performing an Entity Group Transaction against Development Storage?&nbsp; If so, read on.</P>
<P>Recently, I’ve been working on a Windows Azure project, and it’s wonderful that Azure Table Storage now includes support for “Entity Group Transactions”.</P>
<P><A href="https://msdn.microsoft.com/en-us/library/dd894038.aspx" target=_blank mce_href="https://msdn.microsoft.com/en-us/library/dd894038.aspx">Here's the MSDN Documentation Page</A> that explains how the feature works.&nbsp; <A href="https://blog.smarx.com/posts/sample-code-for-batch-transactions-in-windows-azure-tables" target=_blank mce_href="https://blog.smarx.com/posts/sample-code-for-batch-transactions-in-windows-azure-tables">Steve Marx's Blog Posting</A> is a good read, too.</P>
<P>Essentially, this allows one to batch up to 100 insert, update, merge, and delete transactions into a single batch that will either completely succeed or fail.&nbsp; (All the entities in the the transaction must be in the same partition of the same table, and the payload of the transaction cannot exceed 4MB.) </P>
<P>If you want to use Entity Group Transactions with disparate entity types against Development Storage, there is a problem that you will need to workaround.</P>
<P>Given:</P><PRE class=csharpcode>    <SPAN class=kwrd>public</SPAN> <SPAN class=kwrd>class</SPAN> XEntity : TableServiceEntity
    {
        <SPAN class=kwrd>public</SPAN> XEntity(<SPAN class=kwrd>string</SPAN> p, <SPAN class=kwrd>string</SPAN> r)
            : <SPAN class=kwrd>base</SPAN>(p, r) { }
    }

    <SPAN class=kwrd>public</SPAN> <SPAN class=kwrd>class</SPAN> YEntity : TableServiceEntity
    {
        <SPAN class=kwrd>public</SPAN> YEntity(<SPAN class=kwrd>string</SPAN> p, <SPAN class=kwrd>string</SPAN> r)
            : <SPAN class=kwrd>base</SPAN>(p, r) {}
    }</PRE>
<STYLE type=text/css>
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</STYLE>

<P>The following Entity Group Transaction will succeed:</P><PRE class=csharpcode>    tableServiceContext.AddObject(EntitySetName, <SPAN class=kwrd>new</SPAN> XEntity(<SPAN class=str>"Partition1"</SPAN>, <SPAN class=str>"Row1"</SPAN>));
    tableServiceContext.AddObject(EntitySetName, <SPAN class=kwrd>new</SPAN> XEntity(<SPAN class=str>"Partition1"</SPAN>, <SPAN class=str>"Row2"</SPAN>));
    tableServiceContext.SaveChangesWithRetries(SaveChangesOptions.Batch);</PRE>
<P>However, if the entities include distinct properties (XProp and YProp in this example):</P><PRE class=csharpcode>    <SPAN class=kwrd>public</SPAN> <SPAN class=kwrd>class</SPAN> XEntity : TableServiceEntity
    {
        <SPAN class=kwrd>public</SPAN> XEntity(<SPAN class=kwrd>string</SPAN> p, <SPAN class=kwrd>string</SPAN> r)
            : <SPAN class=kwrd>base</SPAN>(p, r) { }

        <SPAN class=kwrd>public</SPAN> <SPAN class=kwrd>string</SPAN> XProp { get; set; }
    }

    <SPAN class=kwrd>public</SPAN> <SPAN class=kwrd>class</SPAN> YEntity : TableServiceEntity
    {
        <SPAN class=kwrd>public</SPAN> YEntity(<SPAN class=kwrd>string</SPAN> p, <SPAN class=kwrd>string</SPAN> r)
            : <SPAN class=kwrd>base</SPAN>(p, r) {}

        <SPAN class=kwrd>public</SPAN> <SPAN class=kwrd>string</SPAN> YProp { get; set; }
    }</PRE>
<P>The following Entity Group Transaction will fail:</P><PRE class=csharpcode>    tableServiceContext.AddObject(EntitySetName, <SPAN class=kwrd>new</SPAN> XEntity(<SPAN class=str>"Partition1"</SPAN>, <SPAN class=str>"Row1"</SPAN>));
    tableServiceContext.AddObject(EntitySetName, <SPAN class=kwrd>new</SPAN> YEntity(<SPAN class=str>"Partition1"</SPAN>, <SPAN class=str>"Row2"</SPAN>));
    tableServiceContext.SaveChangesWithRetries(SaveChangesOptions.Batch);</PRE>
<P>The error will be:</P><PRE class=csharpcode>&lt;?xml version=<SPAN class=str>"1.0"</SPAN> encoding=<SPAN class=str>"utf-8"</SPAN> standalone=<SPAN class=str>"yes"</SPAN>?&gt;
&lt;error xmlns=<SPAN class=str>"https://schemas.microsoft.com/ado/2007/08/dataservices/metadata"</SPAN>&gt;
    &lt;code&gt;InvalidInput&lt;/code&gt;
    &lt;message xml:lang=<SPAN class=str>"en-US"</SPAN>&gt;0:One of the request inputs <SPAN class=kwrd>is</SPAN> not valid.&lt;/message&gt;
&lt;/error&gt;</PRE>
<P>I contacted the Azure team about this issue, and they confirmed that it is a limitation that exists, and will be fixed.</P>
<P>The workaround is simple:</P>
<P>You must store one instance of each entity type appearing in an Entity Group Transaction in the table.&nbsp; So, do this:</P><PRE class=csharpcode>    tableServiceContext.AddObject(EntitySetName, <SPAN class=kwrd>new</SPAN> XEntity(<SPAN class=str>"Dummy"</SPAN>, <SPAN class=str>"DummyX"</SPAN>));
    tableServiceContext.SaveChangesWithRetries();<BR>    tableServiceContext.AddObject(EntitySetName, <SPAN class=kwrd>new</SPAN> YEntity(<SPAN class=str>"Dummy"</SPAN>, <SPAN class=str>"DummyY"</SPAN>));
    tableServiceContext.SaveChangesWithRetries();</PRE>
<STYLE type=text/css>
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</STYLE>

<P>Whenever your table is empty, and then the above example will work.</P>
<P>Best,</P>
<P>Brian</P>
<STYLE type=text/css>
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</STYLE>

<STYLE type=text/css>
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</STYLE>

<STYLE type=text/css>
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</STYLE>]]></content:encoded>
    </item>
    <item>
      <title>Extending the int type to have a For method</title>
      <link>https://docs.microsoft.com/archive/blogs/blambert/extending-the-int-type-to-have-a-for-method</link>
      <pubDate>Wed, 06 Jan 2010 15:51:59 GMT</pubDate>
      <dc:creator><![CDATA[x11mnt]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/blambert/2010/01/06/extending-the-int-type-to-have-a-for-method/</guid>
      <description><![CDATA[It’s been months since I had anything interesting to blog about.&#160; Mostly because I was...]]></description>
      <content:encoded><![CDATA[<p></p>  <p><span class="rem"></span></p>  <p><span class="rem">It’s been months since I had anything interesting to blog about.&#160; Mostly because I was working away on some new stuff I couldn’t talk about.&#160; </span><span class="rem">Anyway, now I feel like blogging again.</span></p>  <p><span class="rem">I’m working on an Azure Worker Role which processes messages from an Azure Queue.&#160; In the main loop of my Worker Role, I had a piece of code like this:</span></p>  <pre class="csharpcode">var messageCount = cloudQueue.RetrieveApproximateMessageCount();
<span class="kwrd">for</span> (var i = 0; i &lt; messageCount; i++)
{
    ThreadPool.QueueUserWorkItem(ProcessQueueMessage);
}</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style><style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p><span class="rem">Simple enough:&#160; Retrieve the approximate message count and queue up enough work items to process the messages.</span></p>

<p><span class="rem">Then I thought, “I’m sick of writing stupid for loops!”</span></p>

<p><span class="rem">So I extended the int type with the following extension method:</span></p>

<pre class="csharpcode"><span class="rem">/// &lt;summary&gt;</span>
<span class="rem">/// Extends int to have a For method.</span>
<span class="rem">/// &lt;/summary&gt;</span>
<span class="rem">/// &lt;param name=&quot;value&quot;&gt;The int being extended.&lt;/param&gt;</span>
<span class="rem">/// &lt;param name=&quot;action&quot;&gt;The Action to execute.&lt;/param&gt;</span>
<span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">void</span> For(<span class="kwrd">this</span> <span class="kwrd">int</span> <span class="kwrd">value</span>, Action action)
{
    <span class="kwrd">for</span> (var i = 0; i &lt; <span class="kwrd">value</span>; i++)
    {
        action();
    }
}</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p>Now, I can write that loop in a single line of code:</p>

<pre class="csharpcode">cloudQueue.RetrieveApproximateMessageCount().For(() =&gt; ThreadPool.QueueUserWorkItem(<span class="kwrd">this</span>.ProcessQueueMessage));</pre>

<p>Which is nice!&#160; Love it.</p>

<p>Then I thought, “What if I need to know the ordinal value of the for loop inside the action, though?”</p>

<p>So I extended the int type with another extension method:</p>

<pre class="csharpcode"><span class="rem">/// &lt;summary&gt;</span>
<span class="rem">/// Extends int to have a For method.</span>
<span class="rem">/// &lt;/summary&gt;</span>
<span class="rem">/// &lt;param name=&quot;value&quot;&gt;The int being extended.&lt;/param&gt;</span>
<span class="rem">/// &lt;param name=&quot;action&quot;&gt;The Action&amp;lt;int&amp;gt; to execute.&lt;/param&gt;</span>
<span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">void</span> For(<span class="kwrd">this</span> <span class="kwrd">int</span> <span class="kwrd">value</span>, Action&lt;<span class="kwrd">int</span>&gt; action)
{
    <span class="kwrd">for</span> (var i = 0; i &lt; <span class="kwrd">value</span>; i++)
    {
        action(i);
    }
}</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p>So now, I can write:</p>

<pre class="csharpcode">10.For(i =&gt; Console.WriteLine(String.Format(<span class="str">&quot;Writing {0}&quot;</span>, i)));</pre>

<p>And see the following output:</p>

<p><font size="2" face="Consolas">Writing 0
    <br />Writing 1

    <br />Writing 2

    <br />Writing 3

    <br />Writing 4

    <br />Writing 5

    <br />Writing 6

    <br />Writing 7

    <br />Writing 8

    <br />Writing 9</font></p>

<p>Of course, I’ll want the same extensions for long, etc.&#160; That’ll be simple enough…</p>

<p>Best,</p>

<p>Brian</p>

<p></p>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>]]></content:encoded>
    </item>
    <item>
      <title>Are you a Maker or a Manager?</title>
      <link>https://docs.microsoft.com/archive/blogs/blambert/are-you-a-maker-or-a-manager</link>
      <pubDate>Thu, 30 Jul 2009 02:08:06 GMT</pubDate>
      <dc:creator><![CDATA[x11mnt]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/blambert/2009/07/30/are-you-a-maker-or-a-manager/</guid>
      <description><![CDATA[Paul Graham writes very useful stuff.&#160; I respect his mind.  Read his Maker’s Schedule,...]]></description>
      <content:encoded><![CDATA[<p><a href="https://www.paulgraham.com/" target="_blank">Paul Graham</a> writes very useful stuff.&#160; I respect his mind.</p>  <p>Read his <a href="https://www.paulgraham.com/makersschedule.html" target="_blank">Maker’s Schedule, Manager’s Schedule</a> essay for what I think is one of the smartest descriptions of the classic problem all programmers face.</p>  <p>Spread this meme in your organization.</p>  <p>Are you a Maker or a Manager?</p>  <p>Both are useful, but they are very different roles.</p>  <p>I am a Maker.&#160; I need two things to be productive:</p>  <ol>   <li>A completely quiet place to work.</li>    <li>Vast chunks of totally uninterrupted time.</li> </ol>  <p>How simple is that?&#160; Turns out, not so simple.&#160; The forces of evil work to ensure that you almost never get either.</p>  <p>Spread the Maker/Manager meme.&#160; </p>  <p>If you’re a Maker, reject 10 AM, 11 AM, 2 PM, and 3 PM meetings.&#160; Write in your response, “Sorry, I’m a Maker, and this doesn’t work for me.”&#160; When someone asks for a meeting, insist on first thing AM, lunchtime, or last thing PM.&#160; Otherwise, no.&#160; No meeting.</p>  <p>You’re a Maker.&#160; Your needs should be respected.&#160; The Makers of the world shouldn’t have to go home to get their work done because the Managers killed their day.</p>  <p>Best,</p>  <p>Brian</p>]]></content:encoded>
    </item>
    <item>
      <title>Stopwatch on Interlocked.Increment(ref x) vs. lock (y) { x++; }</title>
      <link>https://docs.microsoft.com/archive/blogs/blambert/stopwatch-on-interlocked-incrementref-x-vs-lock-y-x</link>
      <pubDate>Fri, 24 Jul 2009 08:43:38 GMT</pubDate>
      <dc:creator><![CDATA[x11mnt]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/blambert/2009/07/24/stopwatch-on-interlocked-incrementref-x-vs-lock-y-x/</guid>
      <description><![CDATA[Given 10 million iterations:  object y = new object();
const int iterations = 10000000;


Which...]]></description>
      <content:encoded><![CDATA[<p>Given 10 million iterations:</p>  <pre class="code"><span style="color: blue">object </span>y = <span style="color: blue">new object</span>();
<span style="color: blue">const int </span>iterations = 10000000;</pre>
<a href="https://11011.net/software/vspaste"></a>

<p>Which is faster, InterlockedIncrement:</p>

<pre class="code">stopWatch = <span style="color: #2b91af">Stopwatch</span>.StartNew();
<span style="color: blue">for </span>(<span style="color: blue">int </span>i = 0; i &lt; iterations; i++)
{
    <span style="color: #2b91af">Interlocked</span>.Increment(<span style="color: blue">ref </span>x);
}
stopWatch.Stop();
<span style="color: #2b91af">Console</span>.WriteLine(<span style="color: #a31515">&quot;Interlocked took &quot; </span>+ stopWatch.ElapsedMilliseconds);</pre>

<p>Or lock:</p>

<pre class="code">stopWatch = <span style="color: #2b91af">Stopwatch</span>.StartNew();
<span style="color: blue">for </span>(<span style="color: blue">int </span>i = 0; i &lt; iterations; i++)
{
    <span style="color: blue">lock </span>(y)
    {
        x++;
    }
}
stopWatch.Stop();
<span style="color: #2b91af">Console</span>.WriteLine(<span style="color: #a31515">&quot;lock took &quot; </span>+ stopWatch.ElapsedMilliseconds);</pre>

<p>The answer surprised me:</p>

<p><font face="Courier New">Interlocked took 168
    <br />lock took 389</font></p>

<p>Best,</p>

<p>Brian</p>]]></content:encoded>
    </item>
    <item>
      <title>A simple and totally thread-safe implementation of IDisposable</title>
      <link>https://docs.microsoft.com/archive/blogs/blambert/a-simple-and-totally-thread-safe-implementation-of-idisposable</link>
      <pubDate>Fri, 24 Jul 2009 07:16:52 GMT</pubDate>
      <dc:creator><![CDATA[x11mnt]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/blambert/2009/07/24/a-simple-and-totally-thread-safe-implementation-of-idisposable/</guid>
      <description><![CDATA[A simple and totally thread-safe implementation of IDisposable, with improved semantics over the...]]></description>
      <content:encoded><![CDATA[<p>A simple and totally thread-safe implementation of IDisposable, with improved semantics over the Dispose() / Dispose(bool disposing) reference implementation.&#160; <em>Now updated, slightly, after a consult with someone much smarter than me, who suggested a slight improvement: use Thread.VolatileRead in the IsUndisposed method.</em></p>  <p><em><strong>Instructions:</strong></em></p>  <p><em>Override DisposeResources in derived classes.&#160; When this method is called, <u>always</u> release unmanaged resources, and dispose of managed resources only if the disposeManagedResources parameter is true.</em></p>  <pre class="code"><span style="color: blue">using </span>System;
<span style="color: blue">using </span>System.Threading;

<span style="color: gray">/// &lt;summary&gt;
/// </span><span style="color: green">DisposableBase class. Represents an implementation of the IDisposable interface.
</span><span style="color: gray">/// &lt;/summary&gt;
</span><span style="color: blue">public abstract class </span><span style="color: #2b91af">DisposableBase </span>: <span style="color: #2b91af">IDisposable
</span>{
    <span style="color: gray">/// &lt;summary&gt;
    /// </span><span style="color: green">A value which indicates the disposable state. 0 indicates undisposed, 1 indicates disposing
    </span><span style="color: gray">/// </span><span style="color: green">or disposed.
    </span><span style="color: gray">/// &lt;/summary&gt;
    </span><span style="color: blue">private int </span>disposableState;

    <span style="color: gray">/// &lt;summary&gt;
    /// </span><span style="color: green">Finalizes an instance of the DisposableBase class.
    </span><span style="color: gray">/// &lt;/summary&gt;
</span>    ~DisposableBase()
    {
        <span style="color: green">// The destructor has been called as a result of finalization, indicating that the object
        // was not disposed of using the Dispose() method. In this case, call the DisposeResources
        // method with the disposeManagedResources flag set to false, indicating that derived classes
        // may only release unmanaged resources.
        </span><span style="color: blue">this</span>.DisposeResources(<span style="color: blue">false</span>);
    }

    <span style="color: gray">/// &lt;summary&gt;
    /// </span><span style="color: green">Gets a value indicating whether the object is undisposed.
    </span><span style="color: gray">/// &lt;/summary&gt;
</span>    <span style="color: blue">public bool </span>IsUndisposed
    {
        <span style="color: blue">get
        </span>{
            <span style="color: blue">return </span><span style="color: #2b91af">Thread</span>.VolatileRead(<span style="color: blue">ref this</span>.disposableState) == 0;
        }
    }

    <span style="color: blue">#region </span>IDisposable Members

    <span style="color: gray">/// &lt;summary&gt;
    /// </span><span style="color: green">Performs application-defined tasks associated with disposing of resources.
    </span><span style="color: gray">/// &lt;/summary&gt;
</span>    <span style="color: blue">public void </span>Dispose()
    {
        <span style="color: green">// Attempt to move the disposable state from 0 to 1. If successful, we can be assured that
        // this thread is the first thread to do so, and can safely dispose of the object.
        </span><span style="color: blue">if </span>(<span style="color: #2b91af">Interlocked</span>.CompareExchange(<span style="color: blue">ref this</span>.disposableState, 1, 0) == 0)
        {
            <span style="color: green">// Call the DisposeResources method with the disposeManagedResources flag set to true, indicating
            // that derived classes may release unmanaged resources and dispose of managed resources.
            </span><span style="color: blue">this</span>.DisposeResources(<span style="color: blue">true</span>);

            <span style="color: green">// Suppress finalization of this object (remove it from the finalization queue and
            // prevent the destructor from being called).
            </span><span style="color: #2b91af">GC</span>.SuppressFinalize(<span style="color: blue">this</span>);
        }
    }

    <span style="color: blue">#endregion </span>IDisposable Members

    <span style="color: gray">/// &lt;summary&gt;
    /// </span><span style="color: green">Dispose resources. Override this method in derived classes. Unmanaged resources should always be released
    </span><span style="color: gray">/// </span><span style="color: green">when this method is called. Managed resources may only be disposed of if disposeManagedResources is true.
    </span><span style="color: gray">/// &lt;/summary&gt;
    /// &lt;param name=&quot;disposeManagedResources&quot;&gt;</span><span style="color: green">A value which indicates whether managed resources may be disposed of.</span><span style="color: gray">&lt;/param&gt;
    </span><span style="color: blue">protected abstract void </span>DisposeResources(<span style="color: blue">bool </span>disposeManagedResources);
}</pre>
<a href="https://11011.net/software/vspaste"></a><a href="https://11011.net/software/vspaste"></a>

<p>Best,</p>

<p>Brian<a href="https://11011.net/software/vspaste"></a><a href="https://11011.net/software/vspaste"></a></p>]]></content:encoded>
    </item>
    <item>
      <title>An invariant version of the same…</title>
      <link>https://docs.microsoft.com/archive/blogs/blambert/an-invariant-version-of-the-same</link>
      <pubDate>Tue, 21 Jul 2009 00:01:49 GMT</pubDate>
      <dc:creator><![CDATA[x11mnt]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/blambert/2009/07/21/an-invariant-version-of-the-same/</guid>
      <description><![CDATA[An invariant version of the same…     /// &lt;summary&gt;
/// Extends StringBuilder so that it has...]]></description>
      <content:encoded><![CDATA[<p>An invariant version of the same…</p>  <blockquote>   <pre class="code"><span style="color: gray">/// &lt;summary&gt;
/// </span><span style="color: green">Extends StringBuilder so that it has an AppendFormatLineInvariant method.
</span><span style="color: gray">/// &lt;/summary&gt;
/// &lt;param name=&quot;value&quot;&gt;</span><span style="color: green">The StringBuilder being extended.</span><span style="color: gray">&lt;/param&gt;
/// &lt;param name=&quot;format&quot;&gt;</span><span style="color: green">A composite format string.</span><span style="color: gray">&lt;/param&gt;
/// &lt;param name=&quot;args&quot;&gt;</span><span style="color: green">An object array that contains zero or more objects to format.</span><span style="color: gray">&lt;/param&gt;
/// &lt;returns&gt;</span><span style="color: green">The StringBuilder.</span><span style="color: gray">&lt;/returns&gt;
</span><span style="color: blue">public static </span><span style="color: #2b91af">StringBuilder </span>AppendFormatLineInvariant(<span style="color: blue">this </span><span style="color: #2b91af">StringBuilder </span>value, <span style="color: blue">string </span>format, <span style="color: blue">params object</span>[] args)
{
    <span style="color: blue">return </span>value.AppendLine(<span style="color: blue">string</span>.Format(<span style="color: #2b91af">CultureInfo</span>.InvariantCulture, format, args));
}</pre>
</blockquote>

<p>Best, </p>

<p>Brian<a href="https://11011.net/software/vspaste"></a></p>]]></content:encoded>
    </item>
    <item>
      <title>A missing method from StringBuilder…</title>
      <link>https://docs.microsoft.com/archive/blogs/blambert/a-missing-method-from-stringbuilder</link>
      <pubDate>Mon, 20 Jul 2009 21:52:22 GMT</pubDate>
      <dc:creator><![CDATA[x11mnt]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/blambert/2009/07/20/a-missing-method-from-stringbuilder/</guid>
      <description><![CDATA[StringBuilder is so useful.&#160; Does it all.&#160; But it’s missing a method.&#160; Here it is:...]]></description>
      <content:encoded><![CDATA[<p>StringBuilder is so useful.&#160; Does it all.&#160; But it’s missing a method.&#160; Here it is:</p>  <blockquote>   <pre class="code"><span style="color: gray">/// &lt;summary&gt;
/// </span><span style="color: green">Extends StringBuilder so that it has an AppendFormatLine method.
</span><span style="color: gray">/// &lt;/summary&gt;
/// &lt;param name=&quot;value&quot;&gt;</span><span style="color: green">The StringBuilder being extended.</span><span style="color: gray">&lt;/param&gt;
/// &lt;param name=&quot;format&quot;&gt;</span><span style="color: green">A composite format string.</span><span style="color: gray">&lt;/param&gt;
/// &lt;param name=&quot;args&quot;&gt;</span><span style="color: green">An object array that contains zero or more objects to format.</span><span style="color: gray">&lt;/param&gt;
/// &lt;returns&gt;</span><span style="color: green">The StringBuilder.</span><span style="color: gray">&lt;/returns&gt;
</span><span style="color: blue">public static </span><span style="color: #2b91af">StringBuilder </span>AppendFormatLine(<span style="color: blue">this </span><span style="color: #2b91af">StringBuilder </span>value, <span style="color: blue">string </span>format, <span style="color: blue">params object</span>[] args)
{
    <span style="color: blue">return </span>value.AppendLine(<span style="color: blue">string</span>.Format(format, args));
}</pre>
</blockquote>

<p><a href="https://11011.net/software/vspaste"></a>So now you can simply code this:</p>

<blockquote>
  <pre class="code">stringBuilder.AppendFormatLine(<span style="color: #a31515">&quot;Here's a line {0}&quot;</span>, <span style="color: #a31515">&quot;YES!&quot;</span>);</pre>
</blockquote>
<a href="https://11011.net/software/vspaste"></a>

<p>Instead of:</p>

<blockquote>
  <pre class="code">stringBuilder.AppendLine(<span style="color: #2b91af">String</span>.Format(<span style="color: #a31515">&quot;Here's a line {0}&quot;</span>, <span style="color: #a31515">&quot;YES!&quot;</span>));</pre>
</blockquote>

<p>Just reads easier, and is simpler to dot through with IntelliSense.</p>

<p>Best,</p>

<p>Brian</p>]]></content:encoded>
    </item>
  </channel>
</rss>