24.10.06

[Advanced Programming] ThreadStatic fields

ThreadStaticAttribute class gives us a very neat (and lazy) method for creating thread level static fields.


Any static field marked with ThreadStatic attribute will be unique for each thread accessing it.



public class ThreadStaticSample
{
   [ThreadStatic]
   private static List<string> stringList;

   // ...
}

No comments: