I'm trying to find some way to start a timer in code, and then check back at some point to see how long it's been running for (in milliseconds preferably). The purpose of this is:
There will be two instances of this program on two networked computers. On a signal they will first sync there timers and then display a question on the screen. As soon as the user on the local computer submits acceptable input, his timer will be stopped. After both inputs are in, the times will be compared to determine who answered first.
If there is a better way to do this please let me know. If you know how to "set a stop watch" that would be great too.
3 replies to this topic
#1
Posted 02 December 2010 - 10:28 AM
|
|
|
#2
Posted 04 December 2010 - 04:46 AM
x.Interval = 1000; //Meaning 1 second
x.Start();
//each 1000 milliseconds or 1 second, the Tick function will be called
//double-click your timer in the designer window to make it appear in your code
int time = 0;
private void MyTimer_Tick(...something here...)
{
time++;
}
Ask me if you have any questions.
Are you a newbie programmer trying to learn C#? Check out my small tutorial: Visual C# Programming Basics
#3
Posted 04 December 2010 - 09:04 AM
I think you'll be better off using the Stopwatch class, rather than a form timer (as suggested above). You'll want to look at the Start, Stop, ElapsedMilliseconds, and Reset methods/properties.
#4
Posted 05 December 2010 - 06:47 PM
Thanks Monerath. Your idea was good too Davide, just wasn't precise enough. :)
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









