Form freezes during while loop
问题 I have a piece of code that checks if a certain application is running while (Process.GetProcessesByName("notepad").Length == 0) { System.Threading.Thread.Sleep(1000); } It will check if the user is running notepad but it makes the form freeze and stop responding after a few seconds. I don't know if there is a better solution to fix this problem. 回答1: In this case, you actually want some work done on a thread that's separate from your main UI thread. The ideal scenario would be to leverage