Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Timing Out An Application

Status
Not open for further replies.

Kenjan

Programmer
Mar 4, 2003
13
US
Does anyone have a way or suggestion to time out an application? We have a problem in our development environment with people leaving our application running when they're not at their desk. When we need to do a re-compile and move a dll to the application server, the dll is already in use. The application server is on a network drive that we don't, and can't, have rights to the processes running. Killing the db connection doesn't help, it just leaves the open dll hanging. Another problem is what to do about modal forms?

Any help is greatly appreciated!
 
My suggestion would be to use a global variable like this:

Dim KillTime as Date

Set your form keypreview to true, and in the keydown event for the form, set this variable like this:

KillTime = Now

Also, in the mousemove event for your form, set it the same way.

In this way, the Kill timer is always updated whenever someone is typing or moving the mouse around on the form.

The use a timer on your main form to check the current time
and use DateDiff to compare the # of minutes difference between "Now" and whatever KillTime is. If it gets over your pre-determined maximum, then start the proceedure to exit all open forms.

You would loop through the forms collection and close each form until the count reached 0. Using an On error resume next would let the loop keep running and close any form, even if it's modal. There's lots of threads that have how to do this in them.

Of course, if the user has nay information they want to save or open files, then you will have to handle that before you close out the program.

That's one way to do it.

Robert
 
[smile] Thanks!!! I never have looked at the form keypreview. That little bit of information just cut the code I thought about in half!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top