Monitor .NET Threads

2020-06-04 17:35发布

问题:

Is there any way to monitor/log thread interactions in the .NET runtime much like VisualVM does for Java? I don't have a specific need at the moment but I think it would be nice to see how all the threads in my application interact.

回答1:

I am unfamiliar with VisualVM in Java....but....

If you are trying to accomplish this programmatically...check out the WMI Performance Counters. I am currently working with them myself!

MSDN Link to WMI Performance Counters

Remember If you are trying see the performance counters, use the server explorer in Visual Studio .NET. You can see all of the performance counters on your machine (or a given machine), and their related properties.

For performance Counter Value retrieval, check out this link: MSDN link for Counter Value Retrieval

For a walkthrough on Changing and Retrieving Performance Counter Values, check out this link: MSDN link for Changing/Retrieving Performance Counter Values

If you're not trying to do this programmatically, and if you simply want to view the Windows Performance Monitor tool (Perfmon), you must invoke it from the Administrative Tools menu of the Control Panel (Under Performance)....OR....To open PerfMon, just go to the Start Menu, choose Run and type perfmon.

This is a great tool for visually monitoring threads and processes. This is not done programatically though, and is more for administration and viewing purposes, rather than building the information/tools for a .NET application to use/retrieve. The Perfmon tool is almost identical to the screenshot/image of the VisualVM tool in your post.

Here is a link to Windows Perfmon: The Top Ten Counters:

Perfmon Link

Hopefully this can help put you in the right direction...cheers!



回答2:

The .NET Diagnostics C# Thread Monitoring Application appears to do what you need.

Edit: If you're new to C#, there's a neat wiki you may want to check out specifically for Java Developers.