Skip to content

fix: correct TryKillProcess retry loop condition#145

Open
dchukkapalli-dev wants to merge 1 commit into
k1tbyte:masterfrom
dchukkapalli-dev:fix/trykillprocess-retry-loop
Open

fix: correct TryKillProcess retry loop condition#145
dchukkapalli-dev wants to merge 1 commit into
k1tbyte:masterfrom
dchukkapalli-dev:fix/trykillprocess-retry-loop

Conversation

@dchukkapalli-dev

@dchukkapalli-dev dchukkapalli-dev commented Jul 13, 2026

Copy link
Copy Markdown

Summary

Fixes the TryKillProcess retry-loop condition in WandEnhancer/Utils/Common.cs (see #144).

for (int i = 0; processes.Length > i || i < 5; i++)   // before
for (int i = 0; processes.Length > 0 && i < 5; i++)    // after

The previous condition compared the process count to the loop index, and the || i < 5 forced at least 5 iterations of Thread.Sleep(250) regardless of state — so TryKillProcess stalled ~1.25s before every patch/restore even when WeMod was not running. The new condition retries only while a target process is still alive, capped at 5 attempts.

Changes

  • WandEnhancer/Utils/Common.cs — corrected retry-loop condition (one line + explanatory comment).

Testing

No automated test project exists for the C# solution and I don't have the WeMod runtime; verified by static reasoning about the loop. The change is a one-line condition fix with no API or behaviour change beyond avoiding the needless spin. Please build the solution to confirm compilation per CONTRIBUTING.md.

Fixes #144

The loop "for (int i = 0; processes.Length > i || i < 5; i++)" compared the
process count to the loop index and, because of the "|| i < 5", always ran
at least 5 iterations of Thread.Sleep(250) -- stalling ~1.25s before every
patch/restore even when WeMod was not running.

Use "processes.Length > 0 && i < 5" so it retries only while a target
process is still alive, capped at 5 attempts.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WandEnhancer: TryKillProcess retry loop stalls ~1.25s (wrong loop condition)

1 participant