title: Stopwatch: measuring time and restart immediately without race condition
body: <p>i have a question regarding the Stopwatch class in the .net framework. I want to measure the time a loop iteration takes ( timing in a game )</p>
  
  <pre><code>Stopwatch timer = new Stopwatch();
  timer.Start(); // Edited this in, forgot about that
  while(true)
  {
      var timespan = timer.Elapsed;
      timer.Restart();
      // do something with the timespan
  
      // Do some work here
  }
  </code></pre>
  
  <p>I'm worried that between the measuring and the restart a context switch could happen and some "time" will be lost.
  Does anyone know a way to measure and restart the timer in an atomic way?</p>
  
  <p>Edit: Solutions without a Stopwatch are also welcome</p>