|
-
May 20th, 2010, 06:35 PM
#1
Thread Starter
Fanatic Member
Performance counter error
Hello all,
I have this code sample from a book I'm reading which looks to be incorrect:
Code:
Imports System.Diagnostics
Sub Main
Dim pc As New PerformanceCounter("PerfApp", "Clicks", False) 'excepiton here
pc.Increment()
counterLabel.Content = pc.NextValue().ToString()
End Sub
There excepion message I get is: The requested Performance Counter is not a custom counter, it has to be initialized as ReadOnly.
I looked for a property to see if I can set it but couldn't find one. Anyone know how I can correct this error?
Thanks,
Strick
-
May 20th, 2010, 06:51 PM
#2
Re: Performance counter error
30 seconds in the documentation and you'd have had your answer. Have you read the documentation for the PerformanceCounter constructor you're using? Do you know what the parameters mean?
-
May 20th, 2010, 07:05 PM
#3
Thread Starter
Fanatic Member
Re: Performance counter error
Hello,
Thanks for your response. Yes I know what they mean and still cannot get it to work (spent about an hour trying to get it to work and surfing the net for answers) which is why I turned to the forum as a last resort.
This statement is word for word from a book, so I'm expecting it to work, but it doesn't. I've tried flipping it to true, but I get a "category does not exist" exeption. Since the book says it should be false, I'm trying to get it to work based on how I'm recieving it.
Thanks,
Strick
-
May 20th, 2010, 07:09 PM
#4
Re: Performance counter error
I would recommend that you provide all the relevant information up front. Your first post says you were passing False to the 'readOnly' parameter and the error message you quoted says that the counter needed to be created read-only, so the obvious solution to that is to pass True to that parameter. If you'd already tried that then that would qualify as relevant information.
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
|