public partial class Form1 : Form
{
PortControl MB = new PortControl();
public Form1()
{
......
MB.MyPort.DataReceived += new SerialDataReceivedEventHandler(DataReceived);
}
/// <summary>
/// 如果接受到了数据。
/// </summary>
private void DataReceived(object sender, SerialDataReceivedEventArgs e)
{
textBox1.Text = MB.MyPort.ReadLine();//为什么这里总是报错:另一个线程企图...不是创建它的线程.
}
********************************** 串口控制 *************************************
**************************************************************************************/
public class PortControl
{
private SerialPort MyPort= new SerialPort();
........
}
应该怎么改呀?大家说说呢.我就是想在接收到串口数据时能实时更改textBox1的内容.