From e12f4ccbcd899155cd89021506a7e6f85b096a87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E5=B7=A7?= <625215135@qq.com> Date: Mon, 13 Oct 2025 09:50:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=8E=B7=E5=8F=96=E9=94=AE?= =?UTF-8?q?=E7=9B=98=E5=92=8C=E9=BC=A0=E6=A0=87=E6=B2=A1=E6=9C=89=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DM_Weight/util/CheckComputerFreeState.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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); } } }