C# Program freezes in for loop
问题 I have this code here that starts a process wait 8 seconds and then kill it and again. for (int i = 0; i < 20; i++) { Process pro = new Process(); pro.StartInfo.FileName = @"C:\Program Files (x86)\Mozilla Firefox\firefox.exe"; pro.StartInfo.WindowStyle = ProcessWindowStyle.Minimized; pro.Start(); Thread.Sleep(8000); try { pro.Kill(); Thread.Sleep(1000); } catch { return; } } As i run the application either on debug mode or direct from the .exe , it successfully starts and kills the process