thread won't stop

L

LS

Hello,

I have a windowsforms application which spins a new thread.

Code of the thread
-----------------------------------------------------------------
Sub DoListen()
Dim listener As TcpListener
Dim tcpclient As TcpClient
Try
listener = New TcpListener(System.Net.IPAddress.Any, 9524)
listener.Start()
Do
tcpclient = listener.AcceptTcpClient()
Threading.ThreadPool.QueueUserWorkItem(AddressOf
HandleTcpClient, tcpclient)
Loop Until frmmain.running = False
Catch ex As Exception
Console.WriteLine(" " + ex.Message)
End Try
End Sub

-----------------------------------------------------------------

If I try to stop the thread or if I quit my program the thread keeps on
running.
If I debug the program and pause the thread the program always pauses on the
line :
-> tcpclient = listener.AcceptTcpClient()

Any ideas on how to solve this problem?

Regards
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top