Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
i m working on window app... i m facing problem......actually i want hang my form if user is not working till 5 min .he got a message you have expired ..first u login u can activate......plz solve my problem
 

 

with regards
kuldeep vyas
developer in Real Expert cor pvt ltd.
Posted 10-Oct-12 21:05pm
Comments
Oshtri Deka at 11-Oct-12 2:09am
   
Let us see your code.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You'll need timer to measure idle time and some kind of tracking mechanism to keep track of user's interaction with form. If idle time elapses then you'll have to inform user with MessageBox etc.
In this case I would use System.Timers.Timer class.
private void someTextBox_TextChanged(object sender, EvetArgs e)
{
    //do some work
    ResetIdleTimer();
}
 
private void someCheckBox_ChekChanged(object sender, EvetArgs e)
{
    //do some work
    ResetIdleTimer();
}
 
//.....
//etc. you got the picture
//.....

private void ResetIdleTimer()
{
   idleTimer.Stop();
   idleTimer.Start();
}
 

void idleTimer_Elapsed(object sender, ElapsedEventArgs e)
{
    MessageBox.Show("Whatever you want to say to user");
    //your logging off code  and closing code go here
    //this.Close();
}
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Incorporate a System.Windows.Fomrs.Timer[^]. Set its Interval[^] property to five minutes. Subscribe a method to its Tick[^] event. In that method, disable your Form and show the "You've been logged out..." message.
 
Now you have to catch each and every possible user intaraction. With every user interaction, first Stop[^] the timer, then Start[^] it again. AFAIR that will cause the timer to wait for Interval again. If not, set the interval before calling Start.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 200
1 Kamal Rocks 184
2 PIEBALDconsult 150
3 BillWoodruff 148
4 Jochen Arndt 135
0 OriginalGriff 5,695
1 DamithSL 4,506
2 Maciej Los 4,007
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,190


Advertise | Privacy | Mobile
Web03 | 2.8.141216.1 | Last Updated 11 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100