<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Are you familiar with [ThreadStatic]?</title><link>http://blogs.msdn.com/jfoscoding/archive/2006/07/18/670497.aspx</link><description>If you're stuffing anything in thread local storage, you might be interested in the performance comparison between Thread.SetData and [ThreadStatic] . ThreadStatic is super-cool, if you have a static variable, you can make it static "per-thread" by placing</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>How can I figure out how large my class is?</title><link>http://blogs.msdn.com/jfoscoding/archive/2006/07/18/670497.aspx#670665</link><pubDate>Wed, 19 Jul 2006 09:40:23 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:670665</guid><dc:creator>jfo's coding</dc:creator><description>Phil asks:&lt;br&gt;&lt;br&gt;&amp;amp;quot;Your last post mentions using Marshal.SizeOf to get the byte size of a type that can be...</description></item><item><title>re: Are you familiar with [ThreadStatic]?</title><link>http://blogs.msdn.com/jfoscoding/archive/2006/07/18/670497.aspx#670725</link><pubDate>Wed, 19 Jul 2006 10:47:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:670725</guid><dc:creator>Kobush</dc:creator><description>Instead of figuring out the correct bitmask for your state consts yourself, you can use the static BitVector32.CreateMask() method to do it for you. In this case you can write:&lt;br&gt;&lt;br&gt;static readonly int stateFooInitialized = BitVector32.CreateMask();&lt;br&gt;static readonly int stateGooInitialized = BitVector32.CreateMask(stateFooInitialized );&lt;br&gt;&lt;br&gt;Note that in second call you should put the previous mask. &lt;br&gt;&lt;br&gt;Another great feature of BitVector32 I've learned recently is bit packing. You can read more here: &lt;a rel="nofollow" target="_new" href="http://adoguy.com/viewrant.aspx?id=2016"&gt;http://adoguy.com/viewrant.aspx?id=2016&lt;/a&gt;&lt;br&gt;</description></item><item><title>re: Are you familiar with [ThreadStatic]?</title><link>http://blogs.msdn.com/jfoscoding/archive/2006/07/18/670497.aspx#670753</link><pubDate>Wed, 19 Jul 2006 11:38:17 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:670753</guid><dc:creator>Ben Hollis</dc:creator><description>Man, I always learn the coolest things from your blog.&lt;br&gt;&lt;br&gt;It's interesting, I love annotations, but I find them much harder to discover than normal Framework classes. I stumble on new classes and methods all the time via Intellisense, but I don't know that I've ever found an annotation that way.</description></item><item><title>re: Are you familiar with [ThreadStatic]?</title><link>http://blogs.msdn.com/jfoscoding/archive/2006/07/18/670497.aspx#671483</link><pubDate>Wed, 19 Jul 2006 18:10:53 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:671483</guid><dc:creator>jfoscoding</dc:creator><description>Kobush - CreateMask is really cool. &amp;nbsp;I believe theres also something like CreateSection if you want to map in more than one bit. &amp;nbsp;Some folks use this to stash away enumerations.&lt;br&gt;&lt;br&gt;The reason I didn't use CreateMask here is that I would have to store it off statically, which meant that instead of holding onto booleans, I was holding on to integers - so basically I wouldn't shave off any room.&lt;br&gt;&lt;br&gt;The const would get replaced by the compiler, so it would not take up room.&lt;br&gt;&lt;br&gt;I find CreateMask is only helpful when you're remembering non-static state. </description></item><item><title>re: Are you familiar with [ThreadStatic]?</title><link>http://blogs.msdn.com/jfoscoding/archive/2006/07/18/670497.aspx#671792</link><pubDate>Wed, 19 Jul 2006 23:31:05 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:671792</guid><dc:creator>Kobush</dc:creator><description>Ok, in that case it makes perfect sense to use const instead. I've only used BitVector32 for classes that have lots of instances (e.g. ORM metadata), so sacrificing few statics to store masks wasn't big deal. &lt;br&gt;&lt;br&gt;Thanks for another great .NET tip!!!</description></item><item><title>re: Are you familiar with [ThreadStatic]?</title><link>http://blogs.msdn.com/jfoscoding/archive/2006/07/18/670497.aspx#671959</link><pubDate>Thu, 20 Jul 2006 02:09:54 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:671959</guid><dc:creator>ricom</dc:creator><description>With this code:&lt;br&gt;&lt;br&gt;[ThreadStatic]&lt;br&gt;private static BitVector32 _state = new BitVector32();&lt;br&gt;&lt;br&gt;The reason this works is that BitVector32 is a value type so there is no real pointer initialization and it will be ok if subsequent threads don't run that constructor.&lt;br&gt;&lt;br&gt;If that wasn't the case then we would just be trading one initialization problem (the strings) for another (the BitVector).&lt;br&gt;&lt;br&gt;Also, we'd probalby have race-conditions galore trying to atomically update a bit in the BitVector except that by design this BitVector is thread local.&lt;br&gt;&lt;br&gt;Be careful out there, setting a bit is not generally an atomic operation. &amp;nbsp;I bet this guy doesn't use InterlockedCompareExchange to set the bit -- I'd be surprised if it did because that would tank the perf in the normal cases.&lt;br&gt;</description></item><item><title>Intersting Finds: July 19, 2006</title><link>http://blogs.msdn.com/jfoscoding/archive/2006/07/18/670497.aspx#672122</link><pubDate>Thu, 20 Jul 2006 05:50:17 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:672122</guid><dc:creator>Jason Haley</dc:creator><description /></item><item><title>Interesting Finds: July 19, 2006</title><link>http://blogs.msdn.com/jfoscoding/archive/2006/07/18/670497.aspx#672123</link><pubDate>Thu, 20 Jul 2006 05:50:36 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:672123</guid><dc:creator>Jason Haley</dc:creator><description /></item><item><title>re: Are you familiar with [ThreadStatic]?</title><link>http://blogs.msdn.com/jfoscoding/archive/2006/07/18/670497.aspx#672767</link><pubDate>Thu, 20 Jul 2006 18:02:35 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:672767</guid><dc:creator>jfoscoding</dc:creator><description>Rico - the most common place for ThreadStatic to be used is for UI caches. &amp;nbsp;Quite a lot of the graphic objects cannot be accessed from another thread. &amp;nbsp;For example, holding onto a System.Drawing.Image or Graphics object statically is a big nono.</description></item><item><title>Technical Related Notes  &amp;raquo; Blog Archive   &amp;raquo; links for 2006-07-21</title><link>http://blogs.msdn.com/jfoscoding/archive/2006/07/18/670497.aspx#677482</link><pubDate>Tue, 25 Jul 2006 06:27:39 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:677482</guid><dc:creator>Technical Related Notes  » Blog Archive   » links for 2006-07-21</dc:creator><description>PingBack from &lt;a rel="nofollow" target="_new" href="http://technote.thedeveloperside.com/?p=58"&gt;http://technote.thedeveloperside.com/?p=58&lt;/a&gt;</description></item><item><title>Extract Embedded Resources With An Attribute In MbUnit</title><link>http://blogs.msdn.com/jfoscoding/archive/2006/07/18/670497.aspx#2301976</link><pubDate>Fri, 27 Apr 2007 21:47:31 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2301976</guid><dc:creator>Community Blogs</dc:creator><description>&lt;p&gt;A long time ago Patrick Cauldwell wrote up a technique for managing external files within unit tests&lt;/p&gt;
</description></item><item><title>Are you familiar with [ThreadStatic]?</title><link>http://blogs.msdn.com/jfoscoding/archive/2006/07/18/670497.aspx#7194025</link><pubDate>Tue, 22 Jan 2008 09:42:04 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7194025</guid><dc:creator>flyingchen</dc:creator><description>&lt;p&gt;转载：&lt;a rel="nofollow" target="_new" href="http://blogs.msdn.com/jfoscoding/archive/2006/07/18/670497.aspx"&gt;http://blogs.msdn.com/jfoscoding/archive/2006/07/18/670497.aspx&lt;/a&gt;&lt;/p&gt;
</description></item></channel></rss>