Want to build the ChatGPT based Apps? Start here
Become a member
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
C# Corner Home
Technologies
Monthly Leaders
ASK A QUESTION
Forum guidelines
adam gills
2.1k
65
12.6k
Set timer on Start botton click
Jan 28 2017 12:01 AM
Hi,
I build a timer which is start on click button and stop after 10 minutes.
I want to know that if click on start button during timer running then its restart from 0,
but timer not reset .
int minremain =600000;
private void timer1_Tick(object sender, EventArgs e)
{
minremain = minremain - 60;
string Sec = string.Empty;
string Min = string.Empty;
if (minremain <= 0)
{
lbltimer.Text = "";
timer1.Stop();
return;
}
else
{
var timeSpan =TimeSpan.FromMilliseconds(Convert.ToDouble(minremain));
var seconds = timeSpan.Seconds;
var minutes = timeSpan.Minutes;
if (seconds.ToString().Length.Equals(1))
{
Sec = "0" + seconds.ToString();
}
else
{
Sec = seconds.ToString();
}
if (minutes.ToString().Length.Equals(1))
{
Min = "0" + minutes.ToString();
}
else
{
Min = minutes.ToString();
}
string Totaltime = "Remaing Time: " + Min + ":" + Sec;
lbltimer.Text = Totaltime;
}
private void btnstartrefresh_Click(object sender, EventArgs e)
{
timer1.Start();
}
So please tell me how to reset timer from start position.
Reply
Answers (
3
)
Difference between Response.Redirect and Server.Transfer?
pagination in mvc without using entity framework