推 Wermut: comport.Open()有在原本的code裡面嗎 05/13 05:38
謝謝,有加了,後來還找到個要加Thread的方法就不會卡在if判別不動了
tProf = new Thread(ReceiveProf);
tProf.IsBackground = true;
tProf.Start();
但是在傳輸接收檔案時if (comport.BreakState)一直判定false(沒有中斷)
即使我把線拔掉他還是顯示false
while (receiving)
{
Byte[] buffer = new Byte[1024];
Int32 length = comport.Read(buffer, 0, buffer.Length);
Array.Resize(ref buffer, length);
fsOut.Write(buffer, 0, length);
if (comport.BreakState)
{
text = "2";
}
else
{
text = "1";
}
Display d = new Display(DisplayText);
this.Invoke(d, new Object[] { text });
}
textbox一直顯示1,怎麼拔都不會變2
※ 編輯: tom2911138 (140.112.17.251), 05/13/2015 11:45:33
→ daimom: 拔掉要停一陣子才會變成timeout吧..不過在那之前 05/25 23:45
→ daimom: 應該會先跳error才對. 05/25 23:46
→ daimom: 剛看了一下msdn,文中是寫發生於傳輸暫停,線路會成中斷狀態 05/25 23:48
→ tom2911138: 有了有了,後來改用serialpingchange事件有抓到中斷了 05/30 15:17
→ tom2911138: 謝謝:D 05/30 15:18