예제 #1
0
        public static bool Open()
        {
            try
            {
                if (serial.IsOpen)
                {
                    serial.Close();
                }
                serial.Open();


                if (thread != null)
                {
                    threadExit = true;
                    thread.Join();
                    thread.Abort();
                    thread = null;
                }
                thread = new Thread(new ThreadStart(ProcessData));
                thread.IsBackground = true;
                thread.Start();

                serial.DtrEnable      = true;
                serial.ErrorReceived += Serial_ErrorReceived;
                serial.DataReceived  += Serial_DataReceived;

                return(true);
            }
            catch (Exception e)
            {
                ClsMessageBox.Exception(e.Message);
            }

            return(false);
        }
예제 #2
0
 public static void Close()
 {
     try
     {
         if (thread != null)
         {
             threadExit = true;
             thread.Join();
             thread.Abort();
             thread = null;
         }
         serial.Close();
     }
     catch (Exception e)
     {
         ClsMessageBox.Exception(e.Message);
     }
 }