Click to See Complete Forum and Search --> : Timers in .NET using C# to calculate time taken


mpd100
04-26-2006, 01:51 PM
i am doing a project .net using c#. in that, i need to be able to record (calculate) the time it takes to complete a quiz in minute /seconds from start to finish.

I dont know how "Timers" work in .net or C#. can anyone help me

Thanking you in advance

nzakas
04-26-2006, 02:11 PM
A good start place is using System.Environment.TickCount, which returns the number of milliseconds that have passed since the OS started. By grabbing this value at different times, you can calculate how much time has passed:


long start = System.Environment.TickCount;

//do other stuff

long stop = System.Environment.TickCount;

long elapsed = stop-start; //total milliseconds passed

long secondsElapsed = elapsed/1000;
long minutesElapsed = secondsElapsed/60;

handshakeit
04-27-2006, 12:05 AM
Hi

its ok to calculate time but can we display time using a lable control or something else on a page decrementing continuously........