你如何限制while循环的CPU?(cpu 使用率 100%)
在这种情况下,while 循环内的代码:
Sub start()
listenerThread = New Thread(AddressOf Listen)
listenerThread.IsBackground = True
listenerThread.Start()
End Sub
enter code here
Sub Listen()
Try
listener = New TcpListener(New IPEndPoint(IPAddress.Any, port))
listener.Start()
a: While (True)
Thread.Sleep(600)
Dim c As New Connection(listener.AcceptTcpClient)
AddHandler c.GotInfo, AddressOf GotInfo
AddHandler c.Disconnected, AddressOf Disconnected
End While
Catch ex As Exception
GoTo a
End Try
End Sub