I had a task to make reflex meter app, and I got and exe as an example. I made it work but I don't get the same results from example I was given and my app, it's like I have 60-70 ms lost somewhere. App is supposed to show a text at random time between 0.5 and 5 seconds and when text shows, the user is supposed to click a button that will stop the stopwatch class I was using here and write it into last and best times.
First I was saving TotalMilliseconds , seconds , milliseconds and minutes as double , and now as TimeSpan, I felt as when I saved it in TimeSpan it reduced time but not enough to be close as example app or even online reflex app. I was thinking about delay between events or even mouse click, but I don't think its supposed to be like 50 60 ms. And if that is the problem how to measure those.
These are start events
private void Start_B_Click(object sender, EventArgs e)
{
Random rnd = new Random();
RndTimer.Interval = rnd.Next(500, 5000);
RndTimer.Start();
}
Stopwatch s = new Stopwatch();
private void RndTimer_Tick(object sender, EventArgs e)
{
NOW_L.Visible = true;
s.Reset();
s.Start();
Random rnd = new Random();
RndTimer.Interval = rnd.Next(500, 5000);
}
and this is button click event
public double o;
private void Click_B_Click(object sender, EventArgs e)
{
if (NOW_L.Visible == true)
{
s.Stop();
TimeSpan ts = s.Elapsed;
NOW_L.Visible = false;
if (LtimeRez_LB.Text == "00:00:00" || ts.TotalMilliseconds < class1.m)
{
LtimeRez_LB.Text = ts.Minutes.ToString() + ":" + ts.Seconds.ToString + ":" +
ts.Milliseconds.ToString();
BesttimeRez_LB.Text = ts.Minutes.ToString() + ":" + ts.Seconds.ToString + ":" +
ts.Milliseconds.ToString();
class1.m = ts.TotalMilliseconds;
o = class1.m;
}
else if (ts.TotalMilliseconds > o || ts.TotalMilliseconds == o)
{
LtimeRez_LB.Text = ts.Minutes.ToString() + ":" + ts.Seconds.ToString + ":" +
ts.Milliseconds.ToString();
}
NOW_L.Visible = false;
}
}
LtimeRez variable is label that is displaying last result and BestTimeRez is best time result, also I used public static double variable called m