Running MSComm_onComm and a TcpListener socket in a separate thread hangs program
I am working with the MSComm Control in VB.NET, and I also run a TcpListener object in a separate thread to listen for incoming requests in an infinite while loop and call MSComm commands when it has received requests to connect to the comm port, send certain commands through the comm port, and so on.
My problem is that when the event MSComm_onComm is raised continuously due to the fact that there is a constant stream of data coming in from the comm port, the whole program freezes.
This problem doesn't occur if I don't have the TcpListener object running, ie. MSComm_onComm runs without any problem at all.
Would appreciate it anyone could explain what is wrong, as I am a newbie at this, Thanks!
Re: Running MSComm_onComm and a TcpListener socket in a separate thread hangs program
Re: Running MSComm_onComm and a TcpListener socket in a separate thread hangs program
Why are you using TcpListener to listen to a serial port? That's just plain wrong...
What is your .net version? If you're coding .Net 2.0 or above, you can use the SerialPort class, which will automatically raises an event when it receives data.
Re: Running MSComm_onComm and a TcpListener socket in a separate thread hangs program
Sorry if my question wasn't clear.
I'm using a TcpListener socket because I would like to be able to control the device which is connected through the serial port remotely. Is there a better method?
I'm using MSComm instead of the SerialPort library because I'm working with a partner's code and he has used MSComm, and I do not have the time now to rewrite his code.