first commit
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace ClassicAssist.Misc
|
||||
{
|
||||
public class OffsetStopwatch : Stopwatch
|
||||
{
|
||||
private TimeSpan _offset;
|
||||
|
||||
public OffsetStopwatch( TimeSpan offset )
|
||||
{
|
||||
_offset = offset;
|
||||
Start();
|
||||
}
|
||||
|
||||
public new long ElapsedMilliseconds => base.ElapsedMilliseconds + (long) _offset.TotalMilliseconds;
|
||||
public new long ElapsedTicks => base.ElapsedTicks + _offset.Ticks;
|
||||
|
||||
public void Reset( TimeSpan offset )
|
||||
{
|
||||
_offset = offset;
|
||||
Reset();
|
||||
Start();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"Elapsed: {TimeSpan.FromMilliseconds( ElapsedMilliseconds )}";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user