timeSetEvent and graphics

Windows specific questions.
deltarho[1859]
Posts: 4308
Joined: Jan 02, 2017 0:34
Location: UK
Contact:

Re: timeSetEvent and graphics

Post by deltarho[1859] »

The first thing that struck me was GetSytemTimes is being used. What if your anti-virus or anti-malware application kicks in for it's daily scan? I would have thought that GetProcessTimes would be a better bet.

However, I think that we are fundamentally flawed by trying to determine process times from within the process itself. We are loading the display thread with more work; Heisenberg strikes again. <smile>

I think that GetProcessTimes is one way to go but that should really be called by a separate process.

Re your code.

I don't like the look of (sys-idl)*100/sys

I would forget about idl and consider the ratio of sys and real time. The real time would be the difference between the current time got just before calling GetSystemTimes in the current instance of the cpu_usage function and the previous instance of the cpu_usage function. This ratio would then give you a CPU load.

With regard real time we could use something like

Code: Select all

RealTime = CurrentTime - LastCurrentTime
where

Code: Select all

Dim As Longint CurrentTime

GetSystemTimeAsFileTime( @CurrentTime )
This is hairy stuff, mister. <laugh>

Added: GetProcessTimes is a bit of a pain - it wants the process handle of the target process. It we use OpenProcess and give that the process id of the target process then we can get the handle. We can get the process id of the target process from Task Manager. Never easy, is it?
Post Reply