I'm developing a tiny UDP console to send some data to test some GPRS devices so I modify an example that I found in CodeProject that it uses one thread; but I get an issue when I want to exit the application, the treahd refuses to stop even if I do something like
If UdpOpen Then
ThreadReceive.Abort()
Me.Dispose()
UdpOpen = False
End If
It halt on the first code line
Private Sub UdpReceive()
Dim receiveBytes As [Byte]() = receivingUdpClient.Receive(RemoteIpEndPoint) '<--Halt here
IpRemote(RemoteIpEndPoint.Address.ToString)
Dim BitDet As BitArray
BitDet = New BitArray(receiveBytes)
Dim strReturnData As String = System.Text.Encoding.ASCII.GetString(receiveBytes)
If UdpOpen Then
StartUdpReceiveThread(CInt(RemotePortLbl.Text))
End If
PrintLog(strReturnData)
End Sub
So I do some research and found, usually, in this Web page the solution Stop a thread that prevents program to close?
And, as says on the first comment, I turn to True the isBackground property and it work, now the question is Why?
Does somebody knows more in deep how it works?