Automatic timeout...

lidds

Junior Contributor
Joined
Nov 9, 2004
Messages
210
I need a bit of help / advice. I'm writing an application (vb.net) at the moment and I am wanting the login screen to reappear after 10 mins of no usage.

My application has a main form called frmMain and uses MDI forms within the main form. The way I was thinking of doing this was adding a onclick method to the frmMain that records a time stamp of every click, and holds within a variable. Then add a timer to the frmMain that every 2mins it checks the current time stamp with the time held in the variable, and if the difference is 10mins or over then displays login form again.

The problem I've got is that I'm not sure if this is the best way to acheive this? Will this slow my application down?

Your help and advice is needed.

Cheers

Simon
 
I would make a class that derives from System.Timers.Timer and add a thread-safe/synchronized method

void Reset()

that resets the timer.


Set the timer for 10 minutes. When the Elapsed is raised, display the login form. Everytime something is clicked, invoke the Reset method. What you described doesn't sound bad either. No human could click fast enough for it to be noticeably slow.
 
Thank for your help, just read up about the system.timers.timer method and sound as if that is the way to go, should be less coding. Will try implementing this tonight, and if works well will post for others.

Simon
 
Back
Top