TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
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
Forums
Monthly Leaders
Forum guidelines
Guest User
Tech Writer
10
0
c# countdown using a timer
Nov 11 2009 8:38 AM
Hello everyone,
I hope I put it in the right section, but I'm rather sure I did.
I have a few problems with my timer.
- It will not go in to the "if (timer1.Interval == 1)"-loop.
- I have no clue how to convert an integer to time, but in a way where I can easily substract 1 second, and go from :00 to :59. (I am assuming I' m going to have to do this converting an integer to a different standard).
- Either the timer, or the progress bar which I use to check the timer with, is awfully "chunky" when it comes to short countings, it seems really unaccurate. (Adjusting the MarqueeAnimationSpeed does not help, I have tried(not sure if this was stupid or not, but I'd like to hear what this actually does, then)).
- Also the .Interval seems NOT to be in milliseconds in my program for some odd reason.
You can see the code below, thanks in advance.
private
void
timer1_Tick(
object
sender, EventArgs e)
{
if
(timer1.Interval == 1)
{
timer1.Stop();
buttonStart.Text =
"Start"
;
buttonStop.Enabled =
false
;
progressBar1.Value = progressBar1.Minimum;
System.Windows.Forms.MessageBox.Show(
"The timer has run out of time"
);
}
if
(progressBar1.Value < 100)
{
progressBar1.Value++;
//labelShowTime.Text = ();
labelShowProgressBarValue.Text = (Convert.ToString(progressBar1.Value) +
"%"
);
}
}
Reply
Answers (
11
)
Opening pdf files from Resources
Passing MultiDimensional Arrays to a method in C#