diff --git a/DM_Weight/util/CheckComputerFreeState.cs b/DM_Weight/util/CheckComputerFreeState.cs index 6ec9b0d..fa31c1c 100644 --- a/DM_Weight/util/CheckComputerFreeState.cs +++ b/DM_Weight/util/CheckComputerFreeState.cs @@ -1,4 +1,9 @@ -using System; +using DM_Weight.Port; +using DM_Weight.ViewModels; +using log4net; +using log4net.Core; +using log4net.Repository.Hierarchy; +using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; @@ -9,6 +14,7 @@ namespace DM_Weight.util { public class CheckComputerFreeState { + private static readonly ILog logger = LogManager.GetLogger(typeof(CheckComputerFreeState)); /// /// 创建结构体用于返回捕获时间 /// @@ -52,15 +58,17 @@ namespace DM_Weight.util long currentTick = Environment.TickCount64; long lastInputTick = vLastInputInfo.dwTime; + logger.Info($"获取用户未操作时间间隔{currentTick}-{lastInputTick}"); // 处理可能的回绕(虽然使用 64 位后极不可能发生) if (currentTick < lastInputTick) { // 发生了回绕,调整计算 lastInputTick -= uint.MaxValue + 1L; } - long elapsedMilliseconds = currentTick - lastInputTick; - return Math.Max(0, elapsedMilliseconds / 1000); + long seconds = elapsedMilliseconds / 1000; + logger.Info($"获取用户未操作时间间隔{currentTick}-{lastInputTick}-{elapsedMilliseconds}-{seconds}-{Math.Max(0, seconds)}"); + return Math.Max(0, seconds); } } }