So I'm writing a program that will call a function CloseAppList() every ten seconds as a coroutine. And CloseAppList() will freeze my application for a few seconds everytime it's called. I discovered that it's when i'm trying to accessp.processname it freeze the program. I also print out the amount of processes is arround 350 which i don't think is much.
Here is my CloseAppList() function:
Process[] processes = Process.GetProcesses ();
string pName = "";
foreach (Process p in processes) {
try{
pName = p.ProcessName;
}catch{
}
}
yield return null;
I'm very confused by how it would freeze my application. Any suggestions would be appreciated.