Skip to content

Commit ef289d7

Browse files
CopilotJack251970
andcommitted
Extract magic numbers to named constants for better maintainability
Co-authored-by: Jack251970 <[email protected]>
1 parent c736eb0 commit ef289d7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

ContextMenuManager/BluePointLilac.Methods/ExternalProgram.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public static void JumpRegEdit(string regPath, string valueName = null, bool mor
3737
process.WaitForInputIdle();
3838

3939
// 等待主窗口句柄可用,最多等待5秒
40-
int retries = 50;
40+
int retries = MAX_WINDOW_WAIT_RETRIES;
4141
while (retries-- > 0)
4242
{
4343
process.Refresh();
@@ -55,7 +55,7 @@ public static void JumpRegEdit(string regPath, string valueName = null, bool mor
5555
// 等待树视图和列表视图控件就绪,最多等待5秒
5656
IntPtr hTree = IntPtr.Zero;
5757
IntPtr hList = IntPtr.Zero;
58-
int retries2 = 50;
58+
int retries2 = MAX_CHILD_WINDOW_WAIT_RETRIES;
5959
while (retries2-- > 0)
6060
{
6161
hTree = FindWindowEx(hMain, IntPtr.Zero, "SysTreeView32", null);
@@ -318,6 +318,8 @@ public static void OpenNotepadWithText(string text)
318318
private const int WM_CHAR = 0x102;
319319
private const int VK_HOME = 0x24;
320320
private const int VK_RIGHT = 0x27;
321+
private const int MAX_WINDOW_WAIT_RETRIES = 50; // 等待主窗口最多5秒 (50 * 100ms)
322+
private const int MAX_CHILD_WINDOW_WAIT_RETRIES = 50; // 等待子窗口最多5秒 (50 * 100ms)
321323

322324
[DllImport("user32.dll")]
323325
private static extern bool ShowWindowAsync(IntPtr hWnd, int cmdShow);

0 commit comments

Comments
 (0)