diff --git a/ATxCommon/SystemChecks.cs b/ATxCommon/SystemChecks.cs index cd8aed8b450361562b3bd188cf4c2222126a0a85..6cbcd665657e7963ef38ff8b193bd702895a3d02 100644 --- a/ATxCommon/SystemChecks.cs +++ b/ATxCommon/SystemChecks.cs @@ -150,5 +150,15 @@ namespace ATxCommon Log.Debug("Currently running processes: {0}", procs.Substring(2)); } } + + /// <summary> + /// Get the current system uptime in seconds. Note that this will miss all times where the + /// system had been suspended / hibernated, as it is based on the OS's ticks counter. + /// </summary> + /// <returns>The time since the last system boot in seconds.</returns> + public static long Uptime() { + var ticks = Stopwatch.GetTimestamp(); + return ticks / Stopwatch.Frequency; + } } }