From 04de5d83c0b5c5eb3cd5c0797cb8846585e708b8 Mon Sep 17 00:00:00 2001
From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch>
Date: Thu, 25 Apr 2019 15:20:29 +0200
Subject: [PATCH] Add SystemChecks.Uptime

Refers to #20
---
 ATxCommon/SystemChecks.cs | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/ATxCommon/SystemChecks.cs b/ATxCommon/SystemChecks.cs
index cd8aed8..6cbcd66 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;
+        }
     }
 }
-- 
GitLab