mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-05 22:36:05 +02:00
Fix uptime crash
This commit is contained in:
@@ -8,12 +8,20 @@ namespace VRCX
|
|||||||
public class AppApiVr
|
public class AppApiVr
|
||||||
{
|
{
|
||||||
public static readonly AppApiVr Instance;
|
public static readonly AppApiVr Instance;
|
||||||
|
private static readonly PerformanceCounter Uptime;
|
||||||
private readonly PerformanceCounter _uptime = new PerformanceCounter("System", "System Up Time");
|
|
||||||
|
|
||||||
static AppApiVr()
|
static AppApiVr()
|
||||||
{
|
{
|
||||||
Instance = new AppApiVr();
|
Instance = new AppApiVr();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Uptime = new PerformanceCounter("System", "System Up Time");
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
Uptime = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void VrInit()
|
public void VrInit()
|
||||||
@@ -47,8 +55,11 @@ namespace VRCX
|
|||||||
/// <returns>The number of milliseconds that the system has been running.</returns>
|
/// <returns>The number of milliseconds that the system has been running.</returns>
|
||||||
public double GetUptime()
|
public double GetUptime()
|
||||||
{
|
{
|
||||||
_uptime.NextValue();
|
if (Uptime == null)
|
||||||
return TimeSpan.FromSeconds(_uptime.NextValue()).TotalMilliseconds;
|
return 0;
|
||||||
|
|
||||||
|
Uptime.NextValue();
|
||||||
|
return TimeSpan.FromSeconds(Uptime.NextValue()).TotalMilliseconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user