Windows – When exactly does a Windows program pause running

screensavertimerwindows xp

I have an app that needs to run for long period unattended on Windows XP and 7. I have it running on a remote machine that has LogMeIn installed so I can look at it from afar. The program has regular logging tasks that are paced by timers.

I had noticed that if the PC was set up to screensave after a delay, and then present the user login screen on exit from the screensaver, my app would stop working when the PC went into screen saver.

When I log in remotely and kick it out of screen saver it continues from where it left off, but there is no data logged in the intervening period.

I thought I had solved it by unchecking the "on resume, show welcome screen" checkbox in the screensaver options, but the problem seems to be back again. I tried disabling the screensaver altogether – no luck.

How can I make sure my program keeps running at all times? I know at the welcome screen Windows tells me I have "x programs running", but that doesn't seem to extend to Windows timers, at least some of the time.


More information:

I've added some debug code and have a bit more information.

The app is a Delphi 2006 GUI app. One of the regular tasks it does is to generate a report. While the report is being generated (it can take some time) I show a progress bar. This is implemented as a modal form where all the processing happens in an OnPaint handler.

I have found that if the report is triggered after the screen saver has kicked in and the "on resume, show welcome screen" checkbox is checked, the OnPaint method of this modal form never fires. The form's OnShow event fires and the app then hangs. As soon as we kick out of screensaver and resume, the OnPaint event executes and everything happens.

My original assumption that the timer events weren't firing while the screensaver was active was wrong. In fact, other code to prevent re-entrancy of the timer event was preventing anything from happening until the report was finished, and the report was snagged at the OnPaint event.

Any suggestions as to how to implement this progress form in a way that it will run when the PC has screen-saved to the Welcome screen?

Best Answer

You could set your program to run as a service. This way it is always running in the background.
That way you could lock the system and your application would still run.
The free tool Servify This would suit your needs perfectly.

Download Servify

Related Question