Merge pull request #1218 from AndreyAkinshin/master
authorMiguel de Icaza <miguel@gnome.org>
Wed, 23 Sep 2015 19:36:55 +0000 (15:36 -0400)
committerMiguel de Icaza <miguel@gnome.org>
Wed, 23 Sep 2015 19:36:55 +0000 (15:36 -0400)
Suppression of negative Elapsed in Stopwatch, this is the comment from the Reference Source:

                    // When measuring small time periods the StopWatch.Elapsed*
                    // properties can return negative values.  This is due to
                    // bugs in the basic input/output system (BIOS) or the hardware
                    // abstraction layer (HAL) on machines with variable-speed CPUs
                    // (e.g. Intel SpeedStep).

1  2 
mcs/class/System/System.Diagnostics/Stopwatch.cs

index 4fcd04293bd595a075e7b956ea5f47ac73e24a19,404a08c8e9b72e31478b9ec97ee640869979d8c2..d66e2d4c3207385c4b9ad88a4c63ee5db50284a1
@@@ -113,15 -113,19 +113,17 @@@ namespace System.Diagnostic
                        if (!is_running)
                                return;
                        elapsed += GetTimestamp () - started;
+                       if (elapsed < 0)
+                               elapsed = 0;
                        is_running = false;
                }
  
 -#if NET_4_0
                public void Restart ()
                {
                        started = GetTimestamp ();
                        elapsed = 0;
                        is_running = true;
                }
 -#endif
        }
  }