private void button1_Click(object sender, EventArgs e) { if (plc == null) { plc = new FormPLC(); plc.Show(); } else { MessageBox.Show("已经打开PLC数据监听!"); } }
private void Form1_Load(object sender, EventArgs e) { plc = new FormPLC(); plc.Show(); btn_close.Enabled = false; tx_port.Text = "9009"; SetMsg("已开始服务!"); btn_start.Enabled = false; btn_close.Enabled = true; myThead = new Thread(new ThreadStart(BeginListen)); myTheadA = new Thread(new ThreadStart(BeginListenA)); myThead.Start(); myTheadA.Start(); }