Reputation: 9
trying to do a countdown timer in C# on micrsoft visual studio minimum value of 10seconds, maximum of 2hours need a display when timer runs out how do i implement this? thanks
Upvotes: 0
Views: 2176
Reputation: 18430
Use timers from System.Timer
or System.Threading .Timer
depends upon your needs. and execute your code in each interval.
have a look at
http://msdn.microsoft.com/en-us/library/system.timers.timer.aspx
and
http://msdn.microsoft.com/en-us/library/system.threading.timer.aspx
if its a simple winforms app like u mentioned its a countdown app consider Forms.Timer
its easier to implement. Just drag and drop the control from toolbox and perform countdown in Tick
Event.
have a look for it here:
http://msdn.microsoft.com/en-us/library/system.windows.forms.timer.aspx
Upvotes: 1
Reputation: 241769
Use System.Threading.Timer
wherein you can specify how much time should pass until the timer fires, and what code to execute when the timer does fire.
You can also look at the System.Windows.Forms.Timer
.
For a comparison of all the timer-like classes in .NET, check out Comparing the Timer Classes in the .NET Framework.
Upvotes: 4