>>The simple way could be to add to your main program
>>
>>on error do ErrorHandler with error(), message() etc. and then have this routine to exit gracefully.
>
>I have a try/catch that assembles an error message and returns it to the webpage when the routine has an error. But what about an infinate loop? In this case there isn't technically an error that would trigger the error handler. The program just goes off and never comes back. So I think I need a timer somehow. But how to add it to the custom class of the EXE and would it even work if the function was stuck in a loop?
Depends on where the loop is. If you're having a do-while loop or some other VFP loop, then just put a counter in the loop, so have a do while nCounter < 20000 or some other number which wouldn't come up in real life, but would eventually come to that if the loop is infin
ite. Of course, increase the counter on each pass.
Another way is to limit the time. Save the current seconds() value plus some predetermined allowed runtime - maybe a minute or two - and once each loop (or each ten passes - your thumb's rule) check whether current value of seconds() is above that.
Either way, you have a criterion on when to bail out, raise an error and let your error handler do the rest. You can have a custom
error "loop took too long, just gave up"
or whatever would not annoy your users too much.