Exemplo n.º 1
0
 /// <summary>Constructs a ThreadLocalVariable.</summary>
 /// <param name="initialValue">Initial value on the current thread.
 /// Does not affect other threads that are already running.</param>
 /// <param name="fallbackValue">Value to use when a given thread
 /// doesn't have an associated value.</param>
 /// <param name="propagator">A function that copies (and possibly
 /// modifies) the Value from a parent thread when starting a new
 /// thread.</param>
 public ThreadLocalVariable(T initialValue, T fallbackValue, Func <T, T> propagator)
 {
     _fallbackValue = fallbackValue;
     Value          = initialValue;
     if (propagator != null)
     {
         _propagator = propagator;
     }
     ThreadEx.RegisterTLV(this);
 }
Exemplo n.º 2
0
 public ThreadLocalVariable()
 {
     ThreadEx.RegisterTLV(this);
 }