[英]Process monitor which takes 100% CPU usage after 5-6 hours
我設計了一個過程監視器,它可以正常工作,但5或6個小時后需要100%的CPU使用率。在物理PC上它可以正常工作,但是在VM上則需要100%使用率。請告訴我問題出在哪兒。編碼部分有兩個線程一個用於刪除已關閉的進程,另一個用於捕獲新進程。
private void getPorcess()
{
int pid=0;
int pid1=0;
ArrayList oProList1 = new ArrayList();
ArrayList oProList2 = new ArrayList();
while (true)
{
Process[] oPrcs = Process.GetProcesses();
if (oPrcs.Length < oProList1.Count)
{
foreach (Process pr1 in oPrcs)
{
pid1 = pr1.Id;
string p = pr1.ProcessName;
oProList2.Add(pid1);
}
//MessageBox.Show(oProList2.Count.ToString());
oProList1.Clear();
oProList1.AddRange(oProList2);
oProList2.Clear();
}
foreach (Process pr in oPrcs)
{
pid = pr.Id;
if (!oProList1.Contains(pid))
{
oProList1.Add(pid);
string szres = "";
try
{
string prcsname = pr.Modules[0].FileName;
if ("")
{
}
}
catch
{
}
}
}
Thread.Sleep(100);
}
}
請告訴我問題是什么
導致其使用100%CPU的錯誤。
您應該修復此錯誤,以使其不使用100%的CPU。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.