Skip to content

Commit

Permalink
Testing using DateTime.UtcNow, lower precision but it shouldn't be af…
Browse files Browse the repository at this point in the history
…fected by loosing focus
  • Loading branch information
runxc1 committed Mar 31, 2024
1 parent 297530f commit a8019ba
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Framework/PausableStopWatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ public class PausableStopWatch
private long _ticksMarker = 0;
public void Start()
{
_ticksMarker = Environment.TickCount;
_ticksMarker = DateTime.UtcNow.Ticks;
}
public void Stop()
{
var now = Environment.TickCount;
var now = DateTime.UtcNow.Ticks;
if(_ticksMarker > 0)
{
_totalTicks += now - _ticksMarker;
Expand All @@ -42,11 +42,11 @@ public TimeSpan Elapsed
{
get
{
var now = Environment.TickCount;
var now = DateTime.UtcNow.Ticks;
var elapsed = _totalTicks;
if (_ticksMarker > 0)
elapsed += now - _ticksMarker;
return TimeSpan.FromMilliseconds(elapsed);
return new TimeSpan(elapsed);
}
}
}
Expand Down

0 comments on commit a8019ba

Please sign in to comment.