Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting up a 'Timeout' feature in windows forms app

Dows anyone know how I can build a timeout feature into a windows forms app.

The app is event driven, but I am thinking of somehow using a timer which counts down for say 10minutes, and one the timer ticks then we time out the user.

The problem I have is how can I reset the timer each time the mouse is moved or clicked.

Any help appreciated.

Cheers

like image 821
Richard.Gale Avatar asked Mar 12 '26 18:03

Richard.Gale


1 Answers

you can use System.Windows.Forms.Timer.

you can drag it from your toolbox to the designer surface.

Use the properties window to set the Interval Property to the time span you want(miliseconds), the Enabled property should be set to false.

on the for load set the timer Enabled property to true.

(The event handler in the sample are written using c# - sorry about that)

private void Form1_Load(object sender, EventArgs e) { timer1.Enabled = true; }

Double click the timer tick event to register to the event, and close the form on the timer tick

private void timer1_Tick(object sender, EventArgs e) { Close(); }

like image 166
Itai Zolberg Avatar answered Mar 16 '26 01:03

Itai Zolberg