Quantcast
Channel: Monir's Blog
Viewing all articles
Browse latest Browse all 54

C# winform check every 30 mins for log in session

$
0
0

In the Solution Explorer right-click the project and select Properties. Go to the “Settings” tab and create a “SettingInterval”. Make the type “int” for the SettingInterval.

public frmMain()
{
InitializeComponent();
timer1.Tick += Timer1_Tick;
timer1.Interval = 1000;
}
private void Timer1_Tick(object sender, EventArgs e)
{
TimeSpan ts = Expires – DateTime.Now;
if (ts.TotalSeconds < 10)
if (Warning)
{
Warning = false; // this must be before the MessageBox
btnLogIn.BackColor = Color.Orange;
MessageBox.Show(“You have 30 seconds left!”);
}

}

I have a button which will trigger the timer.

private void btnLogIn_Click(object sender, EventArgs e)
{
int NewInterval = 30; //30 min……AccessToken expired in 30 min
Properties.Settings.Default.SettingInterval = NewInterval;
Expires = DateTime.Now.AddMinutes(NewInterval);
Warning = true;
timer1.Start();

}


Viewing all articles
Browse latest Browse all 54

Latest Images

Trending Articles





Latest Images