public void serialcek()
{
while (!exitThread)
{
foreach (ManagementObject currentObject in theSearcher.Get())
{
try
{
textBox1.Text = currentObject["Size"].ToString() + " " + currentObject["PNPDeviceID"].ToString();
currentObject.Dispose();
}
catch (Exception)
{
// MessageBox.Show("Bişiler oldu bende anlamadım");
currentObject.Dispose();
//exitThread = false;
}
}
}
Thread.Sleep(100);
serialcek();
}
我用线程。但几分钟后出现错误。单击按钮是 exitThread 使 true。5 分钟后给出 StackOverflowException 未处理 HResult=-2147023895 错误。
感谢帮助。