none
PerformanceCounter.NextValue() returns zero for non-zero counter RRS feed

  • Question

  • Hello,

    When I try to get "Available Worker Threads" perf. counter using of "Forefront TMG Firewall Service" category using System.Diagnostics.PerformanceCounter I get always zero. Other counters from this cate looks good. I use .NET Framework 4 (Assembly System.dll, v4.0.30319).

    My code:

    var pc = new PerformanceCounter("Forefront TMG Firewall Service", "Available Worker Threads", string.Empty, "TargetIP");
    pc.ReadOnly = true;
    float value = pc.NextValue(); // always returns zero
    Thread.Sleep(1000);
    value = pc.NextValue(); // also always returns zero

    Note: The implementation using Pdh.dll returns correct value (unfortunately we use .NET implementation by default).

    Any help is very appreciated.

    Thanks,

    Lukas

    Tuesday, August 28, 2012 6:56 PM

All replies

  • Hi Lukas,

    Nice to see you.

    Would you like to share the way you use PDH? I think there should be something different.

    As you know, PerformanceCounter does also call WinAPI to get the counters.

    Thank you.


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, August 29, 2012 12:20 PM
    Moderator
  • Hello,

    We've opened the ticket with support, so I'll update this thread when we have any news.

    Thanks,

    Lukas

    Friday, November 9, 2012 3:45 PM
  • Hi Lukas,

    OK, thank you and good luck.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, November 12, 2012 6:05 AM
    Moderator