Q: Max number of threads opening and reading/writing to serial ports MOXA NPort I am using Moxa Nport's. They create around 200 virtual serial (COM) ports and are connected via Ethernet to my computer.
I am building an application which communicates with devices using the SerialPort class.
My question: Is there a maximum number of threads that I can run in parallel to open the ports? And of course to communicate in parallel via the ports?
What do I have to take into account (RAM, Traffic, ect) so that
I can repeat this process safely without having my computer hang himself.
I found this answer but it is only helpful in respect to computational operations concerning the core. But how does it behave with Virtual Serial-Ports?
Please share your knowledge and wisdom with me...

A: SerialPort can only be opened once per port. So, in this case, all threads should share the same SerialPort object (static, maybe). If you have multiple ports, each thread can create its own SerialPort on different port. The maximum number of threads depends on the resources needed by each thread. 200 thread for your 200 ports is very reasonable in general. After all, I/O threads are in waiting (or blocked) state most of the time. If you want to open all the 200 ports at once, I think it would be better to make it in batches: start 20 threads in parallel with a timeout of 500 ms, then another 20, ... and so on. Creating 200 threads that communicate with the same driver at once may cause problems, IMHO
