Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
    
Sounds like the PC is going into some type pf sleep/suspend mode, this is not normal behavior to stop a program when the screensaver runs. It is possible there is something wrong with the program itself. –  Moab Sep 18 '11 at 13:06
    
@Moab, please see additions to question. –  rossmcm Sep 19 '11 at 23:59

4 Answers 4

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

share|improve this answer

You don't have sufficient data in your question for this line of thought,
so, I start with some suppositions which you can affirm first to read the answer further.

  1. Are you using a domain login of some sort on the target machine?
  2. Screensaver usually starts as the system gets locked
  3. In some configurations, a user-login is lost while the system is locked
    (I can't recall the exact concepts here but maybe this happens if you logged in remotely)
    In short, the session might get terminated...
  4. Finally, if your program needs network connectivity (or resources allowed only to your login) these accesses might be revoked as the session is terminated.
    This would leave the application unable to complete in such conditions.

So, if this is your case, the application is unable to complete its activity due to revoked access (as your session ends) and when you login again to 'unlock' the system, the session is restarted and you can restart the application too (which might have timed out and stopped without reaching results). However, it starts normally again as you have a new session running now (but, would result in the same problem as you leave it running -- eventually causing a session termination and a screen lock).

share|improve this answer
    
please see additions to question. –  rossmcm Sep 19 '11 at 23:59

I know this may sound like a more hacked up solution, but could you not just add a bit of code to twitch your mouse every couple of minutes? Nothing major, just add 1, subtract 1 to the current mouse position on either axis.

share|improve this answer
    
Hmmm. I could, but that's addressing the symptom, not the problem. –  rossmcm Oct 12 '11 at 20:10

Final solution I had to adopt was to do the processing in the FormActivate handler. I then had to close the form by posting a message as the Close method doesn't work until after the OnPaint handler has been called. Unlike the OnPaint event, the OnActivate event is called when the PC is in screensaver.

procedure TReportForm.FormShow (Sender: TObject) ;
begin
OnActivate := FormActivate ;      // reinstate the handler (it will be nil from any prior call)
end;

procedure TReportForm.FormActivate (Sender: TObject) ;
begin
OnActivate := nil ;               // prevent it being called recursively
GenerateReport ;
PostMessage (Handle, WM_CLOSE, 0, 0) ;
end ;
share|improve this answer
    
Glad you got it handled, as you wrote this program yourself, you should have asked this on StackOverflow. You would have gotten a answer a lot faster. –  Scott Chamberlain Oct 12 '11 at 20:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.