|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
TCPListener / GUI ResponsivnessA while back I posted a message about multithreading in .NET 2.0 to maintain GUI responsivness while using a TCPListener to monitor a TCP port for transmission. One of the MVP's in the group (Cor Ligthert) mentioned using the queue class to do this. I have, unfortunatly, been unable to date to figure out how to do this. (I have achieved the project in a console application, where a GUI isnt utilized, using the same code I show in my example below.) Does anyone have an example, or other methods, that I can use to achieve a GUI TCPListener implementation? My current implementation revolves around this code (condensed): Dim server As New TcpListener(localAddr, port) While True 'Constant Monitor Dim client As TcpClient = server.AcceptTcpClient() Dim stream As NetworkStream = client.GetStream() then break the stream down into bytes and read its contents End While Obviously the constant While loop is causing an unresponsive GUI, but I dont see another way to constantly wait for a TCP message without multithreading, and if thats the way I need to go I hope someone can provide an example for me. Again, thanks for the help, chrisj Chris Johnson wrote:
Show quoteHide quote > Hey guys, You should launch your TCP Listener in a separate thread. This way your > > A while back I posted a message about multithreading in .NET 2.0 to maintain > GUI responsivness while using a TCPListener to monitor a TCP port for > transmission. One of the MVP's in the group (Cor Ligthert) mentioned using > the queue class to do this. > > I have, unfortunatly, been unable to date to figure out how to do this. (I > have achieved the project in a console application, where a GUI isnt > utilized, using the same code I show in my example below.) Does anyone have > an example, or other methods, that I can use to achieve a GUI TCPListener > implementation? > > My current implementation revolves around this code (condensed): > > > Dim server As New TcpListener(localAddr, port) > While True 'Constant Monitor > > Dim client As TcpClient = server.AcceptTcpClient() > Dim stream As NetworkStream = client.GetStream() > > then break the stream down into bytes and read its contents > > End While > > > Obviously the constant While loop is causing an unresponsive GUI, but I dont > see another way to constantly wait for a TCP message without multithreading, > and if thats the way I need to go I hope someone can provide an example for > me. > > Again, thanks for the help, > chrisj > > GUI has it own thread and will get updates it needs. Chris Chris,
I thought that I had seen that Tom Shelton had been busy with the same problem as yours. http://groups.google.com/group/microsoft.public.dotnet.languages.vb/search?q=tcplistener+tom+shelton& Can you check these threads yourself? I hope they help Cor |
|||||||||||||||||||||||