我对线程知之甚少。我只是有在UI Timer1的,当我把这个while循环的timer1_Tick函数,它是100个区间内:当一个循环在timer1_Tick函数内时出现C#错误
count = port.BytesToRead;
while (count > 0)
{
// get the new byte:
char inchar = (char)port.ReadChar();
// add it to the inputstring:
inputString += inchar;
// if the incoming character is a newline, set a flag
// so the main loop can do something about it:
if (inchar == '\n')
{
stringComplete = true;
}
}
程序停止响应任何UI input.I知道问题是关于线程和UI线程,但我没有什么线程知识,正如我所说的。
那么这样的问题的解决方案是什么
您的计时器是否启用? – imsome1
@ imsome1是的这是 – sabsab
@Dmitry是啊,这就是我现在正在做的事情:P – sabsab