Most of the time theory and practicality do not go hand in hand. What do I mean by that?
You want to shut down a form / app if there is no activity for ‘n’ minutes, what do you do if the user is editing a form and has not saved his changes? Before the shutdown; will you save the changes or revert them? If you save, What if there is field validation and it fires and the user is not at his desk, will you overwrite it and still save, if you revert and the users changes are not saved won’t that piss of the user if he has to reenter especially if it’s a lengthy or a complicated form?
Now you have to have a routine that also checks if the form has been put in an “Edit” mode to handle the above. There are hundreds of reasons why there could be no activity; the user may have gone to a meeting, lunch, get additional information or the bathroom…
If you go along with what has been suggested and put a timer and use the key press or mouse move on a form class, what if 2 forms have been opened, one for reference the other for input, there will be no activity on the reference form and after ‘n’ minutes it will close, how will you handle that? Don’t you think that might be annoying?
These are all cute tricks but have absolutely no value for your app. Be kind to yourself and let Windows time out and put the machine in hibernation mode, If the users find this annoying, it is not your app they will blame but the network administrator and the companies policies, this way when the user returns he/she just has to reenter their password and continue working in your app.
In designing an application always remember, it’s not about you, it’s all about the users. That is the golden rule which we developers sometimes forget. Always put yourself in their place and how your app can make their work easier. That is Value…If this is a 8-5 app, you want them to love working in it the whole day… Word of mouth is a priceless future sales tool especially if you have to provide references to your prospective clients.
I am sure this is not what you wanted to hear… I apologize. As you are “recreating” an app I just thought it may be good for you to consider the above points.
But if you still want to do this, put the timer etc in the _screen object, this way you can just shut the whole app down if there is no activity…
Just my opinion.