diff --git a/ArchiSteamFarm/IPC/Controllers/Api/ASFController.cs b/ArchiSteamFarm/IPC/Controllers/Api/ASFController.cs index 63de0341c..37df1566c 100644 --- a/ArchiSteamFarm/IPC/Controllers/Api/ASFController.cs +++ b/ArchiSteamFarm/IPC/Controllers/Api/ASFController.cs @@ -20,7 +20,6 @@ // limitations under the License. using System; -using System.Diagnostics; using System.IO; using System.Threading.Tasks; using ArchiSteamFarm.IPC.Requests; @@ -39,13 +38,7 @@ namespace ArchiSteamFarm.IPC.Controllers.Api { public ActionResult> ASFGet() { uint memoryUsage = (uint) GC.GetTotalMemory(false) / 1024; - DateTime processStartTime; - - using (Process process = Process.GetCurrentProcess()) { - processStartTime = process.StartTime; - } - - ASFResponse result = new ASFResponse(SharedInfo.BuildInfo.Variant, Program.GlobalConfig, memoryUsage, processStartTime, SharedInfo.Version); + ASFResponse result = new ASFResponse(SharedInfo.BuildInfo.Variant, Program.GlobalConfig, memoryUsage, RuntimeCompatibility.ProcessStartTime, SharedInfo.Version); return Ok(new GenericResponse(result)); } diff --git a/ArchiSteamFarm/RuntimeCompatibility.cs b/ArchiSteamFarm/RuntimeCompatibility.cs index e0d1db82d..6ba530f98 100644 --- a/ArchiSteamFarm/RuntimeCompatibility.cs +++ b/ArchiSteamFarm/RuntimeCompatibility.cs @@ -20,21 +20,37 @@ // limitations under the License. using System; +using System.Diagnostics; using System.Threading.Tasks; #if NETFRAMEWORK using System.Collections.Generic; -#endif - -#if NETFRAMEWORK using System.Net.WebSockets; using System.Threading; #endif namespace ArchiSteamFarm { internal static class RuntimeCompatibility { +#if NETFRAMEWORK + private static readonly DateTime SavedProcessStartTime = DateTime.UtcNow; +#endif + internal static bool IsRunningOnMono => Type.GetType("Mono.Runtime") != null; + internal static DateTime ProcessStartTime { + get { +#if NETFRAMEWORK + if (IsRunningOnMono) { + return SavedProcessStartTime; + } +#endif + + using (Process process = Process.GetCurrentProcess()) { + return process.StartTime; + } + } + } + #pragma warning disable 1998 internal static class File { internal static async Task AppendAllTextAsync(string path, string contents) =>