views:

125

answers:

2

Hi

Is it possible to make Idle time befor exit my program ?

I made Windows mobile C# program and i want that after 5 minut's -

if the user not press any key or tap the screen, the program will exit.

how I can make it ?

thank's in addvance

+8  A: 

start a timer when the user clicks on something (or presses a button) Set the timer interval to 5 minutes. Hook an function to the tick event. In that function call Exit(). On every user input restart the timer

Timer Clock=new Timer();
Clock.Interval=5*60*1000;
Clock.Start();
Clock.Tick+=new EventHandler(Timer_Tick);

 public void Timer_Tick(object sender,EventArgs eArgs)
 {
    System.Windows.Forms.Application.Exit()
 }
PoweRoy
+6  A: 
  • Create a one-shot timer for 5 minutes;
  • re-arm the timer on every user action
  • exit program on expiration.
Adriaan