Reset Timer on click of a button.

Posted by Toashish80 under C# on 1/31/2011 | Points: 10 | Views : 3128 | Status : [Member] | Replies : 2
I have a windows application, where when the user logs in main menu screen opens and a timer starts running. The duration for the timer is configurable. Timer runs every 1 minute. When the user selects a menu option a screen opens and the timer gets reset. In the screen when the user clicks on any button then also the timer gets reset. The issue is when user clicks on the button then there is a delay in reset. For eg: If the timer duration is 5 mins and user clicks on a button on 4: 30 seconds then it would take 30 seconds more before resetting the timer.




Responses

Posted by: Vuyiswamb on: 2/1/2011 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Up
0
Down
when to debug the code, when you click the button does it go immidiately to the line that reset the timer ? leet us see the part that reset the timer.

Thank you for posting at Dotnetfunda
[Administrator]

Toashish80, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Toashish80 on: 2/1/2011 [Member] Starter | Points: 25

Up
0
Down
When I debug the code, it goes automatically to the timer.

Below is the code which gets executed for resetting:

MainMenu frmMain = new MainMenu();
frmMain.lblstripStatus.Text = "CDTE Session expires in " + GetTimeoutInterval().ToString() + " minute(s)";
StopWatch.StartInterval = DateTime.Now;
StopWatch.StopInterval = DateTime.Now.AddMinutes(GetTimeoutInterval());
StopWatch.Start();
frmMain.timer1.Enabled = true;

Toashish80, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response