Link to home
Start Free TrialLog in
Avatar of alexandram
alexandram

asked on

Background process - How to

I wrote a program that runs unattended in public places. It crashes on occasion, strange error messages, etc.. I would like to write a small application that would constantly look for my application and reboot if it disappears.  I want this background process to be very small, no form, etc...

How can I do that.  

Thank you.
ASKER CERTIFIED SOLUTION
Avatar of scrapdog
scrapdog
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Make sure the program is in your startup folder when using this method though!!  

I assumed that "reboot" meant reboot the machine (probably your best bet if the machine will be unattended).
Avatar of alexandram
alexandram

ASKER

What if it crashes so bad that this code does not even get a chance to be executed ? I realize that these should not happen but I just want to be safe. That's why I was thinking of a separate process.  
If you use a separate process, consider this:

1.  Your main program raises an exception, and stops operating normally.  However, the main program is still running.

2.  The background process checks to see if it is running.  It is, so do nothing.


Just because a program crashes doesn't mean that it will close itself automatically.  If it is still there, your background process will think it is still running normally.

If you use the try..except method, without a separate process, any exceptions that your applications raise will be passed to the ExitWindows statement.

Using a separate process would be messy...you would have to account for HOW the application stopped.  If you closed it normally, you would first have to close the background application to stop checking, or your program would reboot every time you closed it!!

If it crashes so bad that the except statement cannot be executed, chances are that the crash occurred due to an external source.  The except statement should catch almost everything.

Hello
   You are looking for a band-aid. Make your application more robust, and find a permanent solution (cure) rather than treating symptoms (which inevitably creates more bugs -- and there is a lot of research that supports this fact). One of the fundamental tenets of quality-driven software development is fixing what you have already before continuing developing.

Best of luck

Edo

PS _Code Complete_ by Steve McConnell is a book you must check out.
Thank you. The proposed solution seems to work well. You convinced me - no background process.