From 3d3b03851e08cca28aeae56bf20e4ff10e06d055 Mon Sep 17 00:00:00 2001 From: qhy040404 Date: Fri, 15 Mar 2024 22:24:47 +0800 Subject: [PATCH] Use SpinWait to wait game window instead of WaitForInputIdle --- ...unchExecutionBetterGenshinImpactAutomationHandlder.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Snap.Hutao/Snap.Hutao/Service/Game/Launching/Handler/LaunchExecutionBetterGenshinImpactAutomationHandlder.cs b/src/Snap.Hutao/Snap.Hutao/Service/Game/Launching/Handler/LaunchExecutionBetterGenshinImpactAutomationHandlder.cs index 79803342..a800e661 100644 --- a/src/Snap.Hutao/Snap.Hutao/Service/Game/Launching/Handler/LaunchExecutionBetterGenshinImpactAutomationHandlder.cs +++ b/src/Snap.Hutao/Snap.Hutao/Service/Game/Launching/Handler/LaunchExecutionBetterGenshinImpactAutomationHandlder.cs @@ -26,11 +26,16 @@ internal sealed class LaunchExecutionBetterGenshinImpactAutomationHandlder : ILa try { context.Logger.LogInformation("Waiting game window to be ready"); - context.Process.WaitForInputIdle(); + + SpinWait spinWait = default; + while (context.Process.MainWindowHandle == IntPtr.Zero) + { + spinWait.SpinOnce(); + } } catch (InvalidOperationException) { - context.Logger.LogInformation("Failed to wait Input idle waiting"); + context.Logger.LogInformation("Failed to get game window handle"); return; }