Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ValueStopwatch.cs
Go to the documentation of this file.
1using System;
3
5
6internal struct ValueStopwatch
7{
8 private static readonly double TimestampToTicks = 10000000.0 / (double)Stopwatch.Frequency;
9
10 private long _startTimestamp;
11
12 public bool IsActive => _startTimestamp != 0;
13
14 private ValueStopwatch(long startTimestamp)
15 {
16 _startTimestamp = startTimestamp;
17 }
18
19 public static ValueStopwatch StartNew()
20 {
22 }
23
25 {
26 if (!IsActive)
27 {
28 throw new InvalidOperationException("An uninitialized, or 'default', ValueStopwatch cannot be used to get elapsed time.");
29 }
30 long timestamp = Stopwatch.GetTimestamp();
31 long num = timestamp - _startTimestamp;
32 long ticks = (long)(TimestampToTicks * (double)num);
33 return new TimeSpan(ticks);
34 }
35}
static readonly long Frequency
Definition Stopwatch.cs:13