title: Recalculating the "state" of 50 objects every second
body: <p>I want to recalculate "StrategyState" of some object every second. I do not want to create a Timer for that, because at the same time, from another thread, I can access "StrategyState" property (also, Timer probably would be too heavy for my simple problem). I defined StrategyState type myself this way:</p>
  
  <pre><code>public enum StrategyState
  {
      OnlyKill,
      Working,
      ClosingStage1,
      ClosingStage2,
      Closed
  }
  </code></pre>
  
  <p>I'm not sure if it will be "thread-safe" to write such object from one thread and to read from another thread.</p>
  
  <p>So I was thinking to "lazy-update" my <code>StrategyState State</code> field, like that:</p>
  
  <pre><code>....
  if ( /* State was not updated for one second or more. */ ) {
      RecalculateState()
  }
  switch (State) {
      .... // Work
  </code></pre>
  
  <p>How do I test state was not updated for one second or more without adding too much latency?</p>
  
  <p>I can obviously create Stopwatch, but note that I need to update about 50 states totally for different objects in different threads. I'm not sure if I should add 50 Stopwatch to the system.
  Probably, it's better to add one Stopwatch and share it, because I guess Stopwatch class is likely thread-safe.</p>
  
  <p>What can you suggest?</p>