all groups > vb.net > january 2006 >
You're in the

vb.net

group:

TCPListener / GUI Responsivness


TCPListener / GUI Responsivness Chris Johnson
1/31/2006 10:19:34 PM
vb.net:
Hey guys,

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

Re: TCPListener / GUI Responsivness Cor Ligthert [MVP]
2/1/2006 12:00:00 AM
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

Re: TCPListener / GUI Responsivness I Don't Like Spam
2/1/2006 2:40:42 AM
[quoted text, click to view]

You should launch your TCP Listener in a separate thread. This way your
GUI has it own thread and will get updates it needs.

AddThis Social Bookmark Button