CPU usage in .net kernel (at least on Windows)

So, PerformanceCounter disappeared into the dotnet core. I understand that this was not compatible with Linux.

This comment here: ( What is the history of performance counters for .NET Core? ), It seems to suggest that if I were ready to run it only on Windows I could “use Windows-specific features,” but I don’t know how I could integrate this into the dotnet core.

The reason I want to do this is to preserve the basic dotnet code base, so I don't need to migrate when there is a cross-platform solution for PerformanceCounter .

So, to summarize my question: how can I start using CPU in the dotnet core when working on Windows?


Other relevant posts I found:

  • This solution seems to suggest that Process.GetCurrentProcess() will be enough that I don't quite understand ( PerformanceCounter provided full CPU utilization for the machine).

  • Quoting through all processes (how does this other post seem to suggest ?) Is not possible (it throws an exception for some processes), and it looks pretty slow, which is a problem for my use case.

+5
source share

Source: https://habr.com/ru/post/1270853/


All Articles