我對線程知之甚少。我只是有在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