|
-
Dec 9th, 2010, 01:13 AM
#1
Thread Starter
Hyperactive Member
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..

what could be the difference to my codes?
Last edited by dr_aybyd; Dec 9th, 2010 at 01:16 AM.
VB 6.0 = "Self-Study" Then
vb.NET = "Self-Study" Then
C# = 'on going study.....
-
Dec 9th, 2010, 01:29 AM
#2
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.
-
Dec 9th, 2010, 01:48 AM
#3
Thread Starter
Hyperactive Member
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..
Last edited by dr_aybyd; Dec 9th, 2010 at 09:09 AM.
VB 6.0 = "Self-Study" Then
vb.NET = "Self-Study" Then
C# = 'on going study.....
-
Dec 9th, 2010, 03:29 AM
#4
New Member
Re: PerformanceCounter question.
 Originally Posted by dr_aybyd
Ahh so the other is in kilobits and mine is kiloBytes..so that there are diff readings... 
What's the difference??
-
Dec 9th, 2010, 03:20 PM
#5
Frenzied Member
Re: PerformanceCounter question.
 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?
-
Dec 9th, 2010, 04:37 PM
#6
Thread Starter
Hyperactive Member
Re: PerformanceCounter question.
 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
VB 6.0 = "Self-Study" Then
vb.NET = "Self-Study" Then
C# = 'on going study.....
-
Dec 9th, 2010, 05:45 PM
#7
Re: PerformanceCounter question.
 Originally Posted by winterwinter
What's the difference??
You should read the information that's already been provided before asking questions
 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.
-
Dec 9th, 2010, 05:54 PM
#8
Thread Starter
Hyperactive Member
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...
Last edited by dr_aybyd; Dec 9th, 2010 at 05:57 PM.
VB 6.0 = "Self-Study" Then
vb.NET = "Self-Study" Then
C# = 'on going study.....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|