I am trying to do CPU intensive background processing from a form based program.
I am using the WH_FOREGROUNDIDLE
to detect the idle. The hook does some processing, updates the form and waits for the hook again.
It works great until I click on some other program and then the hook stops.
If I click on the form, the idle hook begins again.
Is there a way around this? Or I am using the wrong method to accomplish my goal?
You can use GetLastInputInfo to determine if the user is idle for the current process. This is useful for instance in chat programs for marking the user as away. However it does not represent the system-wide idle state. But testing this on a timer would allow you to run your task only when the user is not currently interacting with the application without relying on messages that are only delivered due to user activity.