Click here to Skip to main content
15,889,992 members
Please Sign up or sign in to vote.
3.75/5 (3 votes)
user getting login for a Test
after twenty minutes it get sign out automatically

how can i achieve this in Windows Froms Application using C#
Posted
Comments
Balu Balaji 16-Nov-12 1:08am    
simply
I need to implement an auto logout feature in C#(windows form)

1 solution

Hey buddy, use can use timer for this.
C#
private void Form1_Load(object sender, EventArgs e)
    {
        Timer MyTimer = new Timer();
        MyTimer.Interval = (20 * 60 * 1000); // 20 mins
        MyTimer.Tick += new EventHandler(MyTimer_Tick);
        MyTimer.Start();
    }

    private void MyTimer_Tick(object sender, EventArgs e)
    {
        MessageBox.Show("The form will now be closed.", "Time Elapsed");
        this.Close();
    }
 
Share this answer
 
Comments
Balu Balaji 16-Nov-12 1:33am    
Thanks a Lot Abhishek Pant it's working fine

Thank u very much
kittytaneja 26-Nov-13 4:34am    
sir i want same question answer but little bit change that is i want to give specific time suppose 20 min. same i ill give but if i ill touch my mouse than timer should be start from starting(means 0) and if i ill not touch my mouse last 20 min it will automatically come back to login page please help me for that and provide me code for only windows forms in .net applicatioin
Abhishek Pant 16-Nov-12 1:54am    
Its my pleasure!! happy coding!
Abhishek Pant 26-Nov-13 6:59am    
I think you hould Try WPF and use sessions.
Balu Balaji 16-Nov-12 2:44am    
How can Display Count Down seconds for above Timer control

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900