diff --git a/DD2Switcher/Program.cs b/DD2Switcher/Program.cs index 758817e..267cc5f 100644 --- a/DD2Switcher/Program.cs +++ b/DD2Switcher/Program.cs @@ -222,8 +222,8 @@ namespace DD2Switcher { private static void HandleWaitingToAdvance() { // Start timer to advance after N milliseconds - Console.WriteLine($"Starting 500ms timer in WAITING_TO_ADVANCE state"); - Task.Delay(500).ContinueWith(_ => { + Console.WriteLine($"Starting 20ms timer in WAITING_TO_ADVANCE state"); + Task.Delay(20).ContinueWith(_ => { if (CurrentState == SequenceState.WAITING_TO_ADVANCE) { CurrentState = SequenceState.ADVANCE; Console.WriteLine($"Timer expired, transitioning to ADVANCE state"); @@ -321,7 +321,8 @@ namespace DD2Switcher { if (wParamInt == WM_LBUTTONDOWN || wParamInt == WM_RBUTTONDOWN || wParamInt == WM_MBUTTONDOWN) { if (CurrentState == SequenceState.WAITING_FOR_EVENT) { Console.WriteLine($"Mouse click detected in state: {CurrentState}"); - HandleSequenceEvent(); + // Handle sequence event asynchronously to avoid interfering with mouse event processing + Task.Run(() => HandleSequenceEvent()); } } }