대역폭 모니터링 시스템에서 작업 중입니다. 루프를 보내고 주어진 인스턴스에서 보내거나받는 데이터의 양을 표시하고 싶지만 문제는 처리가 끝나면 시스템이 멈추는 것입니다. 다른 일을하는 동안 시스템에 정의 된대로 텍스트 상자에 결과를 표시하면서 백그라운드에서 작동하게 할 수 있습니다. 함수는 다음과 같습니다.Windows 콘솔 대역폭 모니터링 시스템
Private Function netSpeed() As Boolean
Dim networkInterfaces As New System.Diagnostics.PerformanceCounterCategory("Network Interface")
Dim nics As String() = networkInterfaces.GetInstanceNames()
Dim bytesSent(nics.Length - 1) As System.Diagnostics.PerformanceCounter
Dim bytesReceived(nics.Length - 1) As System.Diagnostics.PerformanceCounter
bytesSent(9) = New System.Diagnostics.PerformanceCounter("Network Interface", "Bytes Sent/sec", nics(9), True)
bytesReceived(9) = New System.Diagnostics.PerformanceCounter("Network Interface", "Bytes received/sec", nics(9), True)
Dim up As Integer
Dim down As Integer
For k As Integer = 0 To 2
up = bytesSent(9).NextValue
down = bytesReceived(9).NextValue
System.Threading.Thread.Sleep(1000)
Next
TextBox1.Text = up
TextBox2.Text = down
Return True
End Function
참고 : 인터페이스 9, 즉 이더넷 인터페이스를 테스트 중입니다. 제안 해 주셔서 감사합니다.
* gui 앱에서는 절대로 절전 모드를 사용하지 마십시오. 대신 타이머를 사용하십시오. –