public void ClosePort()
 {
     if (_FxSerial != null)
     {
         _FxSerial.Dispose();
     }
     _FxSerial = null;
 }
 public void OpenPort()
 {
     if (_FxSerial == null)
     {
         _FxSerial = new FxSerialDeamon();
         _FxSerial.Start(1);
     }
 }
        /// <summary>
        /// �ر��߳�
        /// </summary>
        public void Stop()
        {
            _SerialDeamon.Dispose();
            _SerialDeamon = null;

            _Timer.Dispose();
            _Timer = null;

            _Thead.Abort();
            _Thead.Join();
            _Thead = null;
        }
        /// <summary>
        /// ����ӁES232��ͨѶ�߳�
        /// </summary>
        public void Start(int portNo)
        {
            _SerialDeamon = new FxSerialDeamon();
            _SerialDeamon.Start(portNo);

            _Thead              = new Thread(new ThreadStart(this.DealwithCommunicationRoute));
            _Thead.Name         = "FxCommController";
            _Thead.IsBackground = true;
            _Thead.Start();

            _Timer = new Timer(new TimerCallback(TimerRoute));
            _Timer.Change(TimeSpan.FromSeconds(10), TimeSpan.FromDays(1));
        }
        private EventWaitHandle _WaitHandle;                            // ��ʱͬ�����������ͬ�����ã���ʹ�ñ��ȴ���ρE
        /// <summary>
        /// ��Ĭ�ϴ�������������ƁE		/// ����� COM1 �Զ�����
        /// </summary>
        /// <param name="autoStartFromDefaultSerialPort"></param>
        private FxCommController(bool autoStartFromDefaultSerialPort)
        {
            _WaitHandle = null;

            _DataBlockQueue = new DataBlockQueue <FxCommandArgs>(64, true);

            _SerialDeamon   = null;
            _Thead          = null;
            _Timer          = null;
            _FirstFailtTime = DateTime.MaxValue;
            _StopTheadFlag  = false;

            if (autoStartFromDefaultSerialPort)
            {
                Start(1);
            }
        }