'C# TimeOut Method
I have the following code but it is not executing for the TimeOut object for inactivity
private void Form1_Load(object sender, EventArgs e)
{
Console.WriteLine("booting up....");
programController.init(this);
disableFetchSetData();
label3.Hide();
logoutButton.Hide();
//Added Timer Object to log out of program
Timer MyTimer = new Timer();
MyTimer.Interval = (10 * 60 * 1000); // 10 mins
MyTimer.Tick += new EventHandler(TimeOut);
MyTimer.Start();
}
public void TimeOut(object sender, EventArgs e)
{
MessageBox.Show("The form will now close due to inactivity");
this.Close();
}
Why is this? It is supposed to execute from the Load() of the Form. Since the TimeOut method is an event, it is called upon the Load of the Form.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
