title: Is there any issue with using a StopWatch around Parallel.For or Parallel.ForEach?
body: <p>I am using this logic in a WPF application. I am seeing the execution done in 3seconds visually (from the database), but for some reason the stop watch prints out 17s or more.</p>
  
  <p>The code within the Parallel.For block does a lot of calculations and writes to db. So by visually, I mean from the database select query.</p>
  
  <pre><code>Stopwatch stopwatch = new Stopwatch();
  
              // Begin timing
              stopwatch.Start();
  
              String currentTime = System.DateTime.Now.ToString();
              statusLabel.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Background,
                   new Action(delegate() { statusLabel.Content = "New Minute data processing..." + currentTime; }));
  
  
              int size = NumSymWatching;
  
  
              Parallel.For(0, size, x =&gt;
               {
                 CalculateStudies(SymbolsToWatch[x], SymbolSessions[x]);
                });
  
  
  
              UpdateApplicationStatusTable();
              stopwatch.Stop();
  
              statusLabel.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Background,
                   new Action(delegate() { lblTimer.Content = "Time taken to run: " + stopwatch.Elapsed; }));
              isRunning = false;
  </code></pre>
  
  <p><strong>EDIT</strong>
  After a few tests, I've found that there is no issue with using stopwatch around a Parallel.For loop.</p>