This article is a mirror article of machine translation, please click here to jump to the original article.

View: 3897|Reply: 2

[Source] [Turn]. NET Core

[Copy link]
Posted on 1/15/2023 5:56:15 PM | | | |
.NET/C# to get the current application state (CPU, thread, GC)
https://www.itsvse.com/thread-9515-1-1.html


How to use the . The method of getting CPU usage in NETCore is almost identical to the CPU usage value reported in Task Manager.

In the .NET Framework, many people do this with the PerformanceCounter class, referring to the following code:

But PerformanceCounter is not available in . In fact, there is a TotalProcessorTime property in the System.Diagnostics.Process class, which can count the CPU processor time consumed by the current process in near real time, refer to the following code:



You can see that the program outputs every 2s, and it is observed that the CPU utilization in the output and the task manager is basically the same.

Original link:The hyperlink login is visible.





Previous:IIS URL Rewrite Module Rule Clearing
Next:Introduction to each version of the maximum number of rows on a Microsoft Excel Sheet page
Posted on 1/15/2023 10:56:23 PM |
Learn it
Posted on 1/16/2023 10:02:00 AM |
Learn it
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com