Skip to content

Commit d0c0f75

Browse files
committed
修正启动器是否无限等待的判断错误
1 parent 9debded commit d0c0f75

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

PreLaunchTaskr.Core/Services/Launcher.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ public bool Launch(
9797
return Launch(programInfo, originArgs, asAdmin, waitForExit);
9898
}
9999

100+
private const int TIMEOUT = 3000; // 毫秒
101+
100102
/// <summary>
101103
/// 启动程序,传入参数是原启动参数。本函数会根据用户设置对参数处理,
102104
/// </summary>
@@ -235,7 +237,7 @@ public bool Launch(
235237
}
236238
else // 10 秒内不异常退出就当它正常运行了
237239
{
238-
programProcess.WaitForExit(waitForExit ? 10000 : -1); // 毫秒,-1 表示无限期等待,等效于 WaitForExit()
240+
programProcess.WaitForExit(waitForExit ? -1 : TIMEOUT); // 毫秒,-1 表示无限期等待,等效于 WaitForExit()
239241
}
240242
success = !programProcess.HasExited || programProcess.ExitCode == 0;
241243
}
@@ -259,7 +261,7 @@ public bool Launch(
259261
if (!programProcessAdmin.Start())
260262
return false;
261263

262-
programProcessAdmin.WaitForExit(waitForExit ? 10000 : -1);
264+
programProcessAdmin.WaitForExit(waitForExit ? -1 : TIMEOUT);
263265

264266
return !programProcessAdmin.HasExited || programProcessAdmin.ExitCode == 0;
265267
}

0 commit comments

Comments
 (0)