private void button5_Click(object sender, EventArgs e) { try { if (!Back_Save_worker.IsBusy) { Back_Save_worker.RunWorkerAsync(); } } catch { } }
/*private void DataReceivedEventHandler(object sender, SerialDataReceivedEventArgs e) * { * * try * { * SerialPort sData = (SerialPort)sender; * * string recdata = sData.ReadLine(); * double temperature_sub; * richTextBox1.Invoke((MethodInvoker)delegate { richTextBox1.ScrollToCaret(); richTextBox1.AppendText(recdata); }); * int position1 = recdata.IndexOf("index"); * if(position1!=-1) * { * textBox2.Invoke((MethodInvoker)delegate { textBox2.Text = recdata.Substring(position1+13); }); * temperature_sub=Convert.ToDouble(textBox2.Text); * textBox3.Invoke((MethodInvoker)delegate { textBox3.Text = temperature[0].ToString(); }); * * for(int i=0;i<sample_time-1; i++) * { * temperature[i] = temperature[i+1]; * } * * if(data_count<sample_time) * { * temperature[data_count] = temperature_sub; * data_count++; * } * else * { * for(int i=0;i<sample_time-1; i++) * { * temperature[i] = temperature[i+1]; * } * temperature[sample_time - 1] = temperature_sub; * } * * textBox4.Invoke((MethodInvoker)delegate { textBox4.Text = sample_time.ToString();}); * * * Invoke((MethodInvoker)delegate { * easyChart1.Plot(temperature); * }); * } * } * catch * { * Application.ExitThread(); * * } * }*/ private void button4_Click(object sender, EventArgs e) { backgroundWorker1.CancelAsync(); Back_Save_worker.CancelAsync(); Timer_Backup.CancelAsync(); serialPort1.Close(); if (mytask != null) { running_task = null; mytask.Dispose(); } //Timer stopwatch timerstimer.Stop(); timerstimersw.Stop(); timerstimersw.Reset(); }