main
 1using System.Threading;
 2
 3namespace jive
 4{
 5  public class CurrentThread : ApplicationThread
 6  {
 7    public T provide_slot_for<T>() where T : class, new()
 8    {
 9      var slot = Thread.GetNamedDataSlot(create_key_for<T>());
10      if (null == Thread.GetData(slot)) Thread.SetData(slot, new T());
11      return (T) Thread.GetData(slot);
12    }
13
14    string create_key_for<T>()
15    {
16      return Thread.CurrentThread.ManagedThreadId + GetType().FullName + typeof (T).FullName;
17    }
18  }
19}