﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>Jay R. Wren commented on An elegant ThreadLocal for Silverlight</title><description>My only thought was "be glad you have ConditionalWeakTable"  I'd hate (or I'd like to see it, but I'd hate the added complexity) to see how you would have to do this in SL3 without CWT</description><link>http://ayende.com/4825/an-elegant-threadlocal-for-silverlight#comment13</link><guid>http://ayende.com/4825/an-elegant-threadlocal-for-silverlight#comment13</guid><pubDate>Sun, 22 May 2011 16:30:26 GMT</pubDate></item><item><title>Simone commented on An elegant ThreadLocal for Silverlight</title><description>@Jon, I'd guess because you want the lifecycle of the Value to be tied to that of the TL instance, thus GCed when the TL instance is GCed but not earlier.
</description><link>http://ayende.com/4825/an-elegant-threadlocal-for-silverlight#comment12</link><guid>http://ayende.com/4825/an-elegant-threadlocal-for-silverlight#comment12</guid><pubDate>Sat, 30 Apr 2011 01:08:21 GMT</pubDate></item><item><title>Jon Wingfield commented on An elegant ThreadLocal for Silverlight</title><description>I don't get why you're not using a weak reference instead of the table.  Not in silverlight either?
</description><link>http://ayende.com/4825/an-elegant-threadlocal-for-silverlight#comment11</link><guid>http://ayende.com/4825/an-elegant-threadlocal-for-silverlight#comment11</guid><pubDate>Sat, 30 Apr 2011 00:02:23 GMT</pubDate></item><item><title>Simone commented on An elegant ThreadLocal for Silverlight</title><description>Hi Oren, very nice solution. I think this might be an excellent TDD excercise, do you have any tests that cover your implementation you can share to create a sort of kata on top of them?
</description><link>http://ayende.com/4825/an-elegant-threadlocal-for-silverlight#comment10</link><guid>http://ayende.com/4825/an-elegant-threadlocal-for-silverlight#comment10</guid><pubDate>Thu, 28 Apr 2011 21:16:34 GMT</pubDate></item><item><title>Duarte Nunes commented on An elegant ThreadLocal for Silverlight</title><description>Oops, the ConditionalWeakTable _is_ ThreadStatic. Nevermind my earlier post.
</description><link>http://ayende.com/4825/an-elegant-threadlocal-for-silverlight#comment9</link><guid>http://ayende.com/4825/an-elegant-threadlocal-for-silverlight#comment9</guid><pubDate>Thu, 28 Apr 2011 10:33:14 GMT</pubDate></item><item><title>Duarte Nunes commented on An elegant ThreadLocal for Silverlight</title><description>Hm, let me try again: it's ConditionalWeakTable&lt;Thread, Holder&gt;.
</description><link>http://ayende.com/4825/an-elegant-threadlocal-for-silverlight#comment8</link><guid>http://ayende.com/4825/an-elegant-threadlocal-for-silverlight#comment8</guid><pubDate>Thu, 28 Apr 2011 10:22:04 GMT</pubDate></item><item><title>Duarte Nunes commented on An elegant ThreadLocal for Silverlight</title><description>There's a disadvantage: if you have N threads using the ThreadLocal instance, and N-1 thread exit, then the values that they created will only be GCed when the Nth thread exits. 
  
  
Since ConditionalWeakTable is already thread-safe, I would have:
  
  
private ConditionalWeakTable
&lt;thread,&gt;
 _state;
  
  
and index with Thread.CurrentThread.
</description><link>http://ayende.com/4825/an-elegant-threadlocal-for-silverlight#comment7</link><guid>http://ayende.com/4825/an-elegant-threadlocal-for-silverlight#comment7</guid><pubDate>Thu, 28 Apr 2011 10:16:24 GMT</pubDate></item><item><title>configurator commented on An elegant ThreadLocal for Silverlight</title><description>D'oh, I forgot that this is static... Been using ThreadLocal for too long!
</description><link>http://ayende.com/4825/an-elegant-threadlocal-for-silverlight#comment6</link><guid>http://ayende.com/4825/an-elegant-threadlocal-for-silverlight#comment6</guid><pubDate>Thu, 28 Apr 2011 09:49:32 GMT</pubDate></item><item><title>Ayende Rahien commented on An elegant ThreadLocal for Silverlight</title><description>Configurator,
  
a) it won't be thread static?
  
b) it won't ever get cleaned up?
</description><link>http://ayende.com/4825/an-elegant-threadlocal-for-silverlight#comment5</link><guid>http://ayende.com/4825/an-elegant-threadlocal-for-silverlight#comment5</guid><pubDate>Thu, 28 Apr 2011 09:49:10 GMT</pubDate></item><item><title>configurator commented on An elegant ThreadLocal for Silverlight</title><description>What's wrong with private static Holder _state; ?
</description><link>http://ayende.com/4825/an-elegant-threadlocal-for-silverlight#comment4</link><guid>http://ayende.com/4825/an-elegant-threadlocal-for-silverlight#comment4</guid><pubDate>Thu, 28 Apr 2011 09:48:31 GMT</pubDate></item><item><title>Patrick Huizinga commented on An elegant ThreadLocal for Silverlight</title><description>@configurator
  
Because when a ThreadLocal instance is GCed, you want the value to be cleaned up with it. And since garbage collection is likely on a separate thread, you can't use the finalizer.
</description><link>http://ayende.com/4825/an-elegant-threadlocal-for-silverlight#comment3</link><guid>http://ayende.com/4825/an-elegant-threadlocal-for-silverlight#comment3</guid><pubDate>Thu, 28 Apr 2011 09:47:02 GMT</pubDate></item><item><title>Ayende Rahien commented on An elegant ThreadLocal for Silverlight</title><description>Configurator,
  
Try putting anything else in its place
</description><link>http://ayende.com/4825/an-elegant-threadlocal-for-silverlight#comment2</link><guid>http://ayende.com/4825/an-elegant-threadlocal-for-silverlight#comment2</guid><pubDate>Thu, 28 Apr 2011 09:45:37 GMT</pubDate></item><item><title>configurator commented on An elegant ThreadLocal for Silverlight</title><description>Why do you need the ConditionalWeakTable here though?
</description><link>http://ayende.com/4825/an-elegant-threadlocal-for-silverlight#comment1</link><guid>http://ayende.com/4825/an-elegant-threadlocal-for-silverlight#comment1</guid><pubDate>Thu, 28 Apr 2011 09:44:05 GMT</pubDate></item></channel></rss>