private void button2_Click(object sender, EventArgs e) { //if(thread != null) //{ // isStart = false; // //Thread.Sleep(1000); // //thread.Abort(); // serialPort1.Close(); // thread = null; //} if (serial == null) { return; } serial.Stop(); serial = null; }
CSerialControl serial = null; //시리얼 컨트롤하는 객체 선언 private void button1_Click(object sender, EventArgs e) { //if (thread != null) return; //thread = new Thread(new ThreadStart(SerialListening)); //isStart = true; //thread.Start(); if (serial != null) { return; } serial = new CSerialControl(serialPort1); //시리얼 객체와 텍스트박스 차트 연결 serial.SetTextBox(textBox1); serial.SetChart(chart1); //시리얼 객체 시작 serial.Start(); }