PerformanceCounter question.
I have a function that will get the present upload and download rate of my current connection.
It is working now here is my code used:
Code:
Dim NetSent As New System.Diagnostics.PerformanceCounter
Dim NetReceived As New System.Diagnostics.PerformanceCounter
Dim KBytesSent As Long
Dim KBytesReceived As Long
Do Until Me._Stop
KBytesSent = Convert.ToInt32(Math.Round(NetSent.NextValue / 1024, 0, MidpointRounding.AwayFromZero))
Me.StatusUP.Text = KBytesSent & " kB/s"
KBytesReceived = Convert.ToInt32(Math.Round(NetReceived.NextValue / 1024, 0, MidpointRounding.AwayFromZero))
Me.StatusDown.Text = KBytesReceived & " kB/s"
Threading.Thread.Sleep(1000)
Loop
That code is working..
However if try to use other speed meter I got different readings..
See image.. my app is #1 in image..
http://i51.tinypic.com/4io8ja.png
what could be the difference to my codes?
Re: PerformanceCounter question.
Is it generally out by a factor of 8 by any chance, like 8 bits per byte maybe? "kbps" is kilobits per second, not kilobytes per second.
Re: PerformanceCounter question.
Ahhh I see...
But in where specific part of my codes should I modify to make mine like that?
Should I change my ToInt32? Into Decimal? Or any other way...
I tried String Format.
Code:
[String].Format("{0:n} kbps", pcNetReceived.NextValue / 1024.0)
But only appears 0.00 kbps and do not change as I expected..
Re: PerformanceCounter question.
Quote:
Originally Posted by
dr_aybyd
Ahh so the other is in kilobits and mine is kiloBytes..so that there are diff readings...:afrog:
What's the difference??
Re: PerformanceCounter question.
Quote:
Originally Posted by
dr_aybyd
I have a function that will get the present upload and download rate of my current connection.
It is working now here is my code used:
Code:
Dim NetSent As New System.Diagnostics.PerformanceCounter
Dim NetReceived As New System.Diagnostics.PerformanceCounter
What category & instance name are you using?
Re: PerformanceCounter question.
Quote:
Originally Posted by
nbrege
What category & instance name are you using?
Code:
With NetSent
.CategoryName = "Network Interface"
.CounterName = "Bytes Sent/sec"
.InstanceName = "WAN [PPP_SLIP] Interface"
End With
With NetReceived
.CategoryName = "Network Interface"
.CounterName = "Bytes Received/sec"
.InstanceName = "WAN [PPP_SLIP] Interface"
End With
Re: PerformanceCounter question.
Quote:
Originally Posted by
winterwinter
What's the difference??
You should read the information that's already been provided before asking questions
Quote:
Originally Posted by
jmcilhinney
Is it generally out by a factor of 8 by any chance, like 8 bits per byte maybe? "kbps" is kilobits per second, not kilobytes per second.
Re: PerformanceCounter question.
What should I use
.NextValue
or
.RawValue
If I use RawValue is that also in Bytes format?
@jm
its kilobits...
its my mistake...not kilobytes..
thanks...