-
-
Notifications
You must be signed in to change notification settings - Fork 10
Fix race condition in registry editor navigation on first launch #81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: Jack251970 <[email protected]>
Co-authored-by: Jack251970 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a race condition that occurs when launching the Windows Registry Editor (regedit) for the first time. The issue occurred because Process.Start() returns before the window hierarchy is fully initialized, causing attempts to send navigation messages to window handles that were still IntPtr.Zero, resulting in silent failure.
Changes:
- Added retry logic with polling for main window handle acquisition (up to 5 seconds with 50 retries × 100ms each)
- Added retry logic with polling for child control discovery (tree view and list view controls, also up to 5 seconds)
- Extracted retry constants
MAX_WINDOW_WAIT_RETRIESandMAX_CHILD_WINDOW_WAIT_RETRIESfor better maintainability
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
When regedit is launched for the first time,
Process.Start()returns before the window hierarchy is fully initialized. The code attempted to send navigation messages to window handles that were stillIntPtr.Zero, causing silent failure.Changes
MainWindowHandlewithRefresh()for up to 5s (50×100ms)FindWindowEx()for tree/list views for up to 5s before sending navigation messagesMAX_WINDOW_WAIT_RETRIESandMAX_CHILD_WINDOW_WAIT_RETRIESfor maintainabilityThis also fixes the case where regedit is already open but window handles become stale between calls.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.