Replace System.Diagnostics into .Net Core 2.0 (C#)

4es*_*est 1 .net c# system.diagnostics .net-core

I got method in console app .net 4.6:

using System.Diagnostics;

public static void CPUMonitorTest()
{
   var cpuCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total");
   ...
}
Run Code Online (Sandbox Code Playgroud)

When try to do it into class library .NET Core 2.0 I got problem:

  • the namespace doesn't exisit

What can I do now?

cde*_*dev 5

You need package System.Diagnostics.PerformanceCounter. Install it using package manager or console

Install-Package System.Diagnostics.PerformanceCounter -Version 4.5.0
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述