我正在编写一个Windows服务,用于与串行磁条阅读器和中继板(访问控制系统)进行通信。在另一个程序通过打开与我的服务相同的串行端口“中断”进程后,我遇到了代码停止工作(我得到IOExceptions)的问题。部分代码如下:publicpartialclassService:ServiceBase{ThreadthreadDoorOpener;publicService(){threadDoorOpener=newThread(DoorOpener);}publicvoidDoorOpener(){while(true){SerialPortserialPort=newSerialPo