public void Dispose() { if (this.myThread != null && this.myThread.IsAlive == true) { this.myThread.Abort(); while (this.myThread.IsAlive) { Thread.Sleep(50); } } if (this.com != null) { this.Com.CloseSerialPort(); this.Com = null; } }
public ComfixtureHandle NewComfixtureHandle(int PortNum) { Com com = new Com(); com.strReadSTX = _ComfixtureConfig.GetCom_strReadSTX(); //"0A7B"; //可配置 com.strReadEND = _ComfixtureConfig.GetCom_strReadEND(); //"7D0B"; //可配置 com.Encoder = _ComfixtureConfig.GetCom_Encoder(); //可配置 com.port = PortNum; com.OpenSerialPort("COM" + PortNum.ToString(), _ComfixtureConfig.GetCom_SerialPortSet_BaudRate(), _ComfixtureConfig.GetCom_SerialPortSet_Parity(), _ComfixtureConfig.GetCom_SerialPortSet_DataBits(), _ComfixtureConfig.GetCom_SerialPortSet_StopBits()); //可配置 ComfixtureHandle elOperator = _ComfixtureConfig.GetComfixtureHandle(); //可配置 elOperator.ShowModeName = _ComfixtureConfig.GetComfixtureHandle_ShowModeName(PortNum); //可配置 elOperator.Timeout = _ComfixtureConfig.GetComfixtureHandle_TimeOut(); //可配置 elOperator.Com = com; return elOperator; }