Click here to Skip to main content
14,331,896 members
Rate this:
Please Sign up or sign in to vote.
See more:
private void CountdownTimer_Load(object sender, EventArgs e)
            Timer MyTimer = new Timer();
            MyTimer.Interval = (20 * 60 * 1000); // 20 mins
            MyTimer.Tick += new EventHandler(MyTimer_Tick);

        private void MyTimer_Tick(object sender, EventArgs e)
            MessageBox.Show("time is up");

Timer MyTimer = new Timer();

Timer' is a 'namespace' but is used like a 'type'

how to solve this problem and one more doubt how to give Stopwatch value (minutes,seconds calculation for above timer) to a label
Updated 5-Dec-12 2:17am
Deenuji 5-Dec-12 8:45am
Did u use timers Namespace in this project?
Rate this:
Please Sign up or sign in to vote.

Solution 3

If you run into this issue with a class that shares the same name as a namespace, then you need to fully qualify the class when you use it.
System.Timers.Timer MyTimer...
Rate this:
Please Sign up or sign in to vote.

Solution 4

For resolving error:
You might have given some class name or namespace as 'Timer'. Verify the same and rename accordingly. I noticed one thing: You have to set Enabled property True before Timer.Start()

For showing time on a label:
Store DateTime.Now() to a class level variable just before starting the timer. In the MyTimer_Tick event, subtract this variable from current time. Then you will get a TimeSpan which contains elapsed hours,minutes and seconds.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100