Today I had an interesting request for a task monitor written in Xojo to see how much CPU some processes need and to report when they are stuck (no CPU usage over longer time pointing to deadlock) or run at 100% for a long time. And of course to see if they go away due to crashes.
We use the WindowsWMIMBS class to query the Win32_PerfRawData_PerfProc_Process class. There we can query the current counter for processor usage and by getting total and last value calculate a percentage.
The example will be included in next prerelease.