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

View: 44658|Reply: 3

[Source] .NET/C# to get the current application state (CPU, thread, GC)

[Copy link]
Posted on 2021-1-11 18:13:23 | | | |
.NET/C# gets the CPU usage, GC reclamation, and thread usage of the current application, as shown in the figure below:


CLR Stats. CPU UsagePercent 0 GenCollectCount 0 0 0 0M ThreadPool 32766 32767 1000 1000
{
  "CPU": {
    "UsagePercent": 0.0
  },
  "GC": {
    "Gen0CollectCount": 0,
    "Gen1CollectCount": 0,
    "Gen2CollectCount": 0,
    "HeapMemory": 119816,
    "HeapMemoryFormat": "0 M"
  },
  "Thread": {
    "AvailableCompletionPortThreads": 1000,
    "AvailableWorkerThreads": 32766,
    "UsedCompletionPortThreads": 0,
    "UsedWorkerThreads": 1,
    "MaxCompletionPortThreads": 1000,
    "MaxWorkerThreads": 32767
  }
}

From the returned data, you can see the maximum number of threads allowed, as well as the number of worker threads that are currently available, to keep you informed about the health of your application.

The source code is as follows:

(End)




Previous:.NET (CLS) public language specification
Next:[IIS] ASP.NET Prohibit access to download rar and zip files
 Landlord| Posted on 2021-1-25 16:59:44 |
View app status and statistics ASP.NET Core
https://www.itsvse.com/thread-9536-1-1.html

 Landlord| Posted on 2023-1-15 17:57:03 |
 Landlord| Posted on 2025-8-27 09:22:17 |
GC mandatory garbage collection
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