Results 1 to 3 of 3

Thread: [RESOLVED] why does this does not work on .net 4.0 but works on 3.5?

  1. #1

    Thread Starter
    Junior Member mleo1's Avatar
    Join Date
    Jul 2010
    Location
    Manila
    Posts
    25

    Resolved [RESOLVED] why does this does not work on .net 4.0 but works on 3.5?

    Code:
    Imports System.Threading
    
    Public Class Form1
        Dim performanceCounterCategory As New PerformanceCounterCategory("Network Interface")
        Dim instance As String = PerformanceCounterCategory.GetInstanceNames()(0)
        ' 1st NIC !
        Dim performanceCounterSent As New PerformanceCounter("Network Interface", "Bytes Sent/sec", instance)
        Dim performanceCounterReceived As New PerformanceCounter("Network Interface", "Bytes Received/sec", instance)
    
        Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
            Label1.Text = performanceCounterSent.NextValue() / 1024
            Label2.Text = performanceCounterReceived.NextValue() / 1024
        End Sub
    End Class

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    23,403

    Re: why does this does not work on .net 4.0 but works on 3.5?

    is there an error message?
    do you have all necessary references added?

  3. #3

    Thread Starter
    Junior Member mleo1's Avatar
    Join Date
    Jul 2010
    Location
    Manila
    Posts
    25

    Re: why does this does not work on .net 4.0 but works on 3.5?

    nevermind i figure it out, thanks anyway

    its the indexing

    in 3.5
    0=my hardware 1
    1=my hardware 2

    in 4.0
    0=my hardware 2
    1=my hardware 1

    so I just need to change it to
    Code:
    Dim instance As String = PerformanceCounterCategory.GetInstanceNames()(1)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width