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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Any one know a best way of shutdown your Application?

Status
Not open for further replies.

cvl75

Programmer
Mar 8, 2002
19
US
I am trying to figure out an best way of shutdown my application in an X amount of time if it is inactive, but i am having trouble of figure it out. If anyone knows, please help. I am truly appreciated.

Thank You,
CL
 
It's been a while since I did this and I've only done it in Visual FoxPro, so it might lose a little in the translation (if all of the things are possible in VB - I have only done a couple of projects in VB - so I don't have it all figure out yet), but it'll give you the general idea and you can flesh it out from there if you like.

First have a variable that you can stuff the date & time into.

When the user uses the keyboard or the mouse, place the current date/time PLUS the desired idle time (you called it X above) shutdown into the varible.

Have a timeer on each form that will check this variable and compare it to the current date/time. If the date/time in the variable has passed, shut down. IF not - then do nothing.

I shut down the VFP forms by calling the click event on the Exit/Close buttons on the form from the timer event for example:

If variablename < now() then

cmdExit_click

end if

Good luck & let me know if it works! [spidey] [americanflag] [unclesam]
 
If you place a timer on your form and set a variable to the time that the form loads you could do something like this

Private Sub Timer1_Timer()
If DateDiff(&quot;n&quot;, tStart, Now()) > 1 Then
myShutdown
End If
End Sub

The above could uses the variable tStart As Date that is set to Now() when the form loads. The Timer1 Interval is set to 100 ms and after 1 minute the myShutdown Sub is called. All you have to do is refresh the tStart variable when an activity occurs (ie mouse click etc). Hope this helps. Anything is possible, the problem is I only have one lifetime.[thumbsup2]
 
That's what I currently have it work right now but Since I have so many forms i dont want to have a timer on every form I Just want know if there is way that I can just Have this shutdown my application in my main forms and still be able to keep track all the child forms Activities.

Thank You for such a quick response
 
Do you want the entire application to shut-down after a certain amount of time?

If yes, put the timer only on the MDI Form and when your time amount has ran out do a &quot;End&quot;. But, when there is activity on any of the sub-forms you will need to reset your timer (I don't know of any way around that).

If no, a timer will be nessary on each individual form.

- Bill
 
No one have any other ideas. Like a API call or something similar.

Thank you in advance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top