fix(watcher): fix TickCount wrap and resume retry on API failure
- Use 32-bit Environment.TickCount with unchecked uint arithmetic so GetIdleTime stays correct after the ~49.7 day uint wrap boundary - Only clear _pausedTaskId after successful resume, not before the API call - Add retry path: if resume failed, retry on next poll cycle while user is still active Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -29,6 +29,7 @@ internal static partial class NativeMethods
|
||||
var info = new LASTINPUTINFO { cbSize = (uint)Marshal.SizeOf<LASTINPUTINFO>() };
|
||||
if (!GetLastInputInfo(ref info))
|
||||
return TimeSpan.Zero;
|
||||
return TimeSpan.FromMilliseconds(Environment.TickCount64 - info.dwTime);
|
||||
// Use 32-bit TickCount so both values wrap at the same boundary as dwTime (uint)
|
||||
return TimeSpan.FromMilliseconds(unchecked((uint)Environment.TickCount - info.dwTime));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user