.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)
|