Timer as form inactivity monitor - tick event firing unexpectedly

D

Dan

Hi,

I have a timer on a form (System.Windows.Forms.Timer - Framework 1.1) that
is set to 60 seconds as sort an of inactivity monitor. If 60 seconds have
elapsed without any user activity I want the form to close. I stop/start
the timer at button clicks and keydown events etc of the various controls on
the form. Users have reported the form closing in the middle of them typing
or immediately after opening the form (but only rarely). (The timer is
design-time set to Enabled = false, Interval = 60000) I think I saw this
occur once during testing where an event fired that should have reset the
timer and about 15 seconds later the tick event fired. As a workaround
possibly I am going to store the time of the last reset so that I can
compare to the time when the tick event fires (ie if only 15 seconds have
elapsed instead of 60 then don't do anything). This of course won't help if
rather than a timer failure, its the keydown and other events that are not
firing. Any similiar experiences or other suggestions for monitoring
inactivity (such as using the thread timer).

Regards,

Dan
 
C

CJ Taylor

On your keydown / mouseevents are you calling your timer to stop? reset the
interval, and start again? (reseting the interval isn't important really..)
 
C

Cor

Hi Dan,

When I was you I just would check my reset procedure setting the times
something more narrow.

But I would never use a thread timer, that one I could until now not reset.
(It goes direct in his own thread when it start and fires even if the
program is ended).

For this I find the forms timer the nicest.

Just my thought,

Cor
 
H

Herfried K. Wagner [MVP]

* "Dan said:
I have a timer on a form (System.Windows.Forms.Timer - Framework 1.1) that
is set to 60 seconds as sort an of inactivity monitor. If 60 seconds have
elapsed without any user activity I want the form to close. I stop/start
the timer at button clicks and keydown events etc of the various controls on
the form. Users have reported the form closing in the middle of them typing
or immediately after opening the form (but only rarely). (The timer is
design-time set to Enabled = false, Interval = 60000) I think I saw this
occur once during testing where an event fired that should have reset the
timer and about 15 seconds later the tick event fired. As a workaround
possibly I am going to store the time of the last reset so that I can
compare to the time when the tick event fires (ie if only 15 seconds have
elapsed instead of 60 then don't do anything). This of course won't help if
rather than a timer failure, its the keydown and other events that are not
firing. Any similiar experiences or other suggestions for monitoring
inactivity (such as using the thread timer).

Post the code you use to reset the timer.
 

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