nyholku / purejavacomm

Pure Java implementation of JavaComm SerialPort
http://www.sparetimelabs.com/purejavacomm/index.html
BSD 3-Clause "New" or "Revised" License
362 stars 146 forks source link

Run SerialPortEventListener in other Thread #102

Closed Tsyklop closed 6 years ago

Tsyklop commented 6 years ago

Hi.

Can your make run SerialPortEventListener in new thread?

Thanks.

nyholku commented 6 years ago

Please elaborate I do not understand what you want to do.

Tsyklop commented 6 years ago

@nyholku Now the SerialPortEventListener runs in one thread. I'm doing the Swing application and before I display the window I connect to usb, but because the SerialPortEventListener starts in the same thread, the whole process stops on the SerialPortEventListener and the program does not go any further.

Tsyklop commented 6 years ago

@nyholku for example librarry JSSC run Listener in new Thread and program run success.

nyholku commented 6 years ago

Hmm, not sure I still understand the problem. PJC creates an internal thread for each open port and the SerialPortEventListener gets called from that thread, so unless you block inside the SerialPortEventListener event handling everything should be ok. If you need to do Swing stuff from within the SerialPortEventListener you should use swing utilities invoke methods.

Tsyklop commented 6 years ago

I check again. Sorry. my mistake.