You'll have to put timers on all your forms and check for keystrokes, etc.
It's a lot of trouble.
If what you're trying to do is be able to kick the users out of their
application so they no longer have the shared Access database locked, here's
an alternate idea that I have used before, with much success:
I had an application where my main form stayed open all the time, although
sometimes it was hidden. It opened the connection to the database at
startup, and closed it at shutdown.
I put a timer on the main form. Every couple of minutes, the timer fired,
and it checked to see if there was a file called shutdown.txt in the same
folder as the Access database. The contents of the folder are not relevant,
just the presence of a file with that name.
I had one global static (shared) boolean variable, let's call it
globalShutdown. When the timer fired, if the file was found, the
globalShutdown value was set to true.
In the main form, when globalShutdown was true, it would close all of the
forms, then close itself and the connection to the database.
In each of the other forms' form_closing event, if globalShutdown was true,
it would only close itself. I had to put that in because some of the forms
had Exit options that would close the main form in addiiton to that form,
which you wouldn't want to do if the form was being closed BY the main form.
In the loops in my reports, I put in a check for globalShutdown, and when
true, exited processing and returned to the calling form.
In the calling form, after the report was finished running, it checked
globalShutdown, and didn't continue if it was true.
So when I wanted to shut people out of the database, I just put a file with
that name in the same folder. Within a couple of minutes, everybody was out,
whether they were sitting at their desk or not.
In the main form, when it closes everything (including the link to the
database), the last thing I would do is put up a messagebox saying the
application was being closed because database maintenance was being
performed. The app would sit there at the messagebox for when the user came
back to his desk, but the app wouldn't be connected to the database.
Another thing I did was when the user started up the application, before
starting up the connection to the database, check for the file. If it's
there, give them a message telling them it is being maintained and they
should try again later, and exit the application.
It's not as complicated as it sounds. It worked really well, without fail,
and was a lot easier than trying to figure out how long it's been since the
user last clicked on something or typed something in one of the screens.
Hope this helps.
RobinS.
-------------------------------------------------------
"klaas" <kl***@sdmlfk.nlwrote in message
news:Ov**************@TK2MSFTNGP02.phx.gbl...
Hi,
i spent a lot of time on the web, but i can't figure it out by myself. i
Saw not a suitable example which i can use in my application.
A little more help will be very appreciated.
thx Klaas
"klaas" <kl***@sdmlfk.nlschreef in bericht
news:%2****************@TK2MSFTNGP04.phx.gbl...
>hi,
thank you for your replay.
I want to close my application automaticly because some users often
forget to close the program properly and get awway and the program
remains still open with an open connection to the DB.
If it shuts down after a period of inactivaty , the connection to the DB
will close . I prefer to idlle the thime within the application.
thx, Klaas
"Family Tree Mike" <Fa************@discussions.microsoft.comschreef in
bericht news:41**********************************@microsof t.com...
>>You are basically going to do what is necessary for developing a screen
saver. There should be plenty of examples of doing something similar to
this. The first I found is
http://weblogs.asp.net/jdanforth/arc...21/454219.aspx.
You will code whatever you want to do at the point where it is
determined
the user is idle.
It is a much more difficult thing if you are talking about the user
being
idle in your application rather than the system. For example, if your
user
gets carried away writing some emails, do you consider this idle within
your
application?
By the way... Why would your connections remain open if you are not
using
them? They should be closed when you are through with them.
"klaas" wrote:
Hi,
i'am writing a program in vb.net 2005 based on an access database.
Now, i want to close my program automaticly when the user is inactive
to a
period of eg 10 minutes. I want to close all mine connections to the
database en quit the program.
is there a procedure to achive this or even better an example of this
on
the net?
regards, Klaas