Timers and code...

J

Jack Leach

I have a general question regarding timers.

I'm making an attempt to set up an "idle time" function to kick a user out
if they've been idle for too long, per http://support.microsoft.com/kb/128814

I've got my Timer interval on my hidden form set to 5 seconds, so every 5
seconds the code checks the user activity. If the idle period is over 60
minutes, I want to display a message box:

"The app will quit in X seconds"

So in order to do this, I need a custom "msgbox" form, with a timer interval
of 1000 to "count" from 60 to 0 seconds before quitting (with an option for
the user to cancel).

But what keeps the original timer, set at 5000, to run during the countdown
of my seperate custom message form? Is this as easy as setting the hidden
form's timer interval to 0 before opening my message form?

Me.TimerInterval = 0
DoCmd.OpenForm "frmTimeoutNotice"



I think I've got that right, but this brings up some more questions for me.
Apparently, Timer's will always run, even while code is already running
elsewhere or when a form is opened dialog, etc. If I understand correctly
there's no way to get a timer to stop running unless the Interval is set to 0.

What happens when two "instances" of code run at the same time? How do we
keep control over a timer's code and make sure it isn't interfering with our
"normal" code? There's seems to be no way to tell what other code may be
running when a timer event is called... how do we keep these apart? The idea
seems very messy to me... like you never really know. As you might be able
tell, working with timers are new to me. What happens if you have a timer
event set to 1000 and you're debugging that timer event and it takes you
longer than 1 second to step through the code?

Any insights or pointers to further discussion on how to make sure timers
are used safely?

Thanks,

--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)
 
K

Klatuu

5 seconds is probably more frequently than you really need to check. I would
set it to 1 minute (60000). One way to handle it would be to set the hidden
form's Timer Intervalu to 0. Another would be to close the hidden form.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top