fix(Program.cs): reduce delay in HandleWaitingToAdvance and handle sequence event asynchronously

This commit is contained in:
2025-08-31 22:19:57 +02:00
parent 62f92708c2
commit 12ac48aa76

View File

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