コード例 #1
0
        /*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();
        }
コード例 #2
0
        // Timer

        private void Time_button_Click(object sender, EventArgs e)
        {
            Timer_Backup.RunWorkerAsync();
        }