mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 14:10:53 +00:00
Fix ProcessStartTime on generic-netf mono
This commit is contained in:
@@ -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<GenericResponse<ASFResponse>> 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<ASFResponse>(result));
|
||||
}
|
||||
|
||||
|
||||
@@ -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) =>
|
||||
|
||||
Reference in New Issue
Block a user