' this object is thread that receives data. Dim t As New Threading.Thread(AddressOf ReceiveMessage) ' this function will start the listenning Public Function Listen(ByVal port As Integer) As Boolean _LPort = port _IsListening = True _Timer.Interval = 100 _Timer.Start() _IPEP = New IPEndPoint(IPAddress.Any, _LPort) _UDPlsn = New UdpClient(_IPEP) done = False t.Start() End Function ' this function will stop listenning Public Sub StopListen() IsListening = False done = True t.Abort() End Sub ' this sub is the thread that receive messages from other program. Private Sub ReceiveMessage() Try Do _Data = _UDPlsn.Receive(_IPEP) Loop Until done Catch ex As Exception End Try Threading.Thread.CurrentThread.Abort() End Sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)