我正在尝试监控我的互联网连接的流量,即给定时间的平均速度,以获得平均速度。我已经尝试过这段代码,但它不起作用。我哪里错了?
Function bwmonitor()
Dim pc As New PerformanceCounterCategory("Network Interface")
Dim instance As String = pc.GetInstanceNames(0)
Dim bs As New PerformanceCounter("Network Interface", "Bytes Sent/sec", instance)
Dim br As New PerformanceCounter("Network Interface", "Bytes Received/Sec", instance)
Dim k As Integer = 0
Do
k = k + 1
Dim kbsent As Integer = bs.NextValue() / 1024
Dim kbRecieved As Integer = br.NextValue / 1024
TextBox10.Text = kbsent
TextBox11.Text = kbRecieved
Threading.Thread.Sleep(1000)
Loop Until k = 10
Return 0
End Function
我已经调用了该函数,但文本框只返回零。