mirror of
https://github.com/k1tbyte/Wand-Enhancer.git
synced 2026-08-28 23:01:13 +00:00
Merge pull request #145 from divya0795/fix/trykillprocess-retry-loop
fix: correct TryKillProcess retry loop condition
This commit is contained in:
@@ -11,7 +11,12 @@ namespace WandEnhancer.Utils
|
||||
public static void TryKillProcess(string processName)
|
||||
{
|
||||
Process[] processes = Process.GetProcessesByName(processName);
|
||||
for (int i = 0; processes.Length > i || i < 5; i++)
|
||||
// Retry while any target process is still alive, capped at 5 attempts.
|
||||
// The previous condition (processes.Length > i || i < 5) compared the
|
||||
// process count to the loop index and, because of the "|| i < 5", always
|
||||
// ran at least 5 iterations — sleeping ~1.25s even when the process was
|
||||
// never running.
|
||||
for (int i = 0; processes.Length > 0 && i < 5; i++)
|
||||
{
|
||||
foreach (var process in processes)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user