Click here to Skip to main content
15,909,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I want to learn about Timer Setting with Window Form in C# programming.
i want to learn about how to link with 2 Timers setting and calculate total time and seconds.

Where can i learn it ?
Can u give me address?
Posted
Comments
joshrduncan2012 5-Dec-13 10:50am    
Great question for google.

Depends on what you are trying to do, but I suspect that Timers are not what you want at all.
The Timer class[^] provides events and allows you to do someting at regular intervals - it had nothing to do with "total time and seconds" because it is concerned only with an interval between "ticks": the point at which it signals an event and your code in teh handler method runs automattically. It also isn't that accurate - it depends what else is going on as to when your timer tick event handler executes (it isn't in "real-time" or even close).

What I suspect you want to look at is the Stopwatch class[^] which doesn;t provide any events but is very good (and nicely accurate) at workign out how long it took to do something.

If you want to do something at intervals, or you want to limit how much time users can take to do something, then use a Timer, otherwise, you are probably better off with a Stopwatch.
 
Share this answer
 
Best way would be to do it on your own. This is not difficult topic and you certainly can google it, read documentation in MSDN, try some code and if you find any problem, post the question here.

Only confusing part would be that there are several timers available for programmers to choose from. Which one is the best for you depends on what you want to do with it. But this you didn’t tell us.

But do some reading first.
 
Share this answer
 
i done it c# Windows form application i hope this will helpful for you
this is related to online exam total time calculation......
/* When click on start button */
DateTime from = DateTime.Now;
 
/* when click on end button */
DateTime to = DateTime.Now;
 
/* total time */
TimeSpan total = to - from ;
 
string totalime = to.ToString("t");
 
/* In seconds  */
string totaltime = total.TotalSeconds.ToString();


If you want in minutes or hours there is different methods like totalminutes etc
 
Share this answer
 
Comments
Member 10404120 6-Dec-13 10:59am    
I want to clear what i write in label used by button.
How to do ?
Can u give me advice?
[no name] 7-Dec-13 3:52am    
sorry but i don't get what exactly you want to do ?

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900