sgt_pinky
Regular
Hi,
I have a multithreaded server app (Winforms) that I have converted to a service.
It has a thread that simply creates a new TcpListener and waits for a connection:
This thread runs for the life of the application. The problem is that without using the command 'End', the application is blocking on this thread on the line:
Server.AcceptTcpClient holds up everything. I have tried to Abort() the thread, etc, but that doesn't help.
I can solve the problem using 'End' in the Winforms app, but in the service it causes all kinds of problems, and the program is left running in the taskmanager, even though it says 'Stopped' in the Services manager.
TIA,
Pinky
I have a multithreaded server app (Winforms) that I have converted to a service.
It has a thread that simply creates a new TcpListener and waits for a connection:
Visual Basic:
Public Sub StartListeningThread()
Do
Dim ip As IPAddress = IPAddress.Any
Server = New TcpListener(ip, 4000)
Server.Start()
Dim tcpTmp As TcpClient = Server.AcceptTcpClient
Dim tcpClient As New RUHTcpClient
tcpClient.Client = tcpTmp.Client
Server.Stop()
Connections.Add(tcpClient)
Loop
End Sub
This thread runs for the life of the application. The problem is that without using the command 'End', the application is blocking on this thread on the line:
Visual Basic:
Dim tcpTmp As TcpClient = Server.AcceptTcpClient
Server.AcceptTcpClient holds up everything. I have tried to Abort() the thread, etc, but that doesn't help.
I can solve the problem using 'End' in the Winforms app, but in the service it causes all kinds of problems, and the program is left running in the taskmanager, even though it says 'Stopped' in the Services manager.
TIA,
Pinky