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