OpenNETCF.Stopwatch -> only ticks changing, not Elapsed
- by pithyless
I've been trying to track down a bug I thought was thread-related, but I think instead there is an issue with the way I am using OpenNETCF's Stopwatch. I am using OpenNETCF.IoC in my application, but for the sake of simplicity I moved the following code directly into a view:
public partial class WorkoutView : SmartPart
{
...
private Stopwatch stopwatch;
public WorkoutView()
{ ...
stopwatch = new Stopwatch();
stopwatch.Reset();
stopwatch.Start();
WorkoutDisplayTimer = new Timer();
WorkoutDisplayTimer.Interval = 500;
WorkoutDisplayTimer.Tick += new EventHandler(WorkoutDisplayTimer_Tick);
WorkoutDisplayTimer.Enabled = true;
}
void WorkoutDisplayTimer_Tick(object sender, EventArgs e)
{ ...
stopwatch.Stop();
lbl.Text = stopwatch.ElapsedTicks.ToString() + "NOT WORKING: " + stopwatch.Elapsed.ToString();
stopwatch.Start();
}
...
}
Long story short, looking at stopwatch in the debugger, the only values that ever get updated are ElapsedTicks, mElapsed, mStartPerfCount. Everything else is always zero. Is this expected behavior? Do I need to call an additional method to have the stopwatch calculate the Elapsed struct? (Note: stopwatch.ElapsedMilliseconds is also zero)