You are correct, my class had a pretty big bug in it, thanks for pointing that out. I updated it and it should work fine now.
- Netduino Forums
- → Viewing Profile: Posts: Drasive
The Netduino forums have been replaced by new forums at community.wildernesslabs.co.
This site has been preserved for archival purposes only
and the ability to make new accounts or posts has been turned off.
Community Stats
- Group Members
- Active Posts 2
- Profile Views 4633
- Member Title New Member
- Age Age Unknown
- Birthday Birthday Unknown
-
Gender
Not Telling
0
Neutral
User Tools
Friends
Drasive hasn't added any friends yet.
Latest Visitors
No latest visitors to show
Posts I've Made
In Topic: System.Diagnostics.Stopwatch class
30 December 2013 - 09:35 PM
In Topic: System.Diagnostics.Stopwatch class
03 June 2013 - 01:54 PM
I extended the class a little further:
using System; namespace System.Diagnostics { public class Stopwatch { private long _ticksAtStart; private long _ticksNow; public bool IsRunning { get; private set; } public TimeSpan ElapsedDuration { get { return IsRunning ? new TimeSpan(0, 0, 0, 0, (int)((Microsoft.SPOT.Hardware.Utility.GetMachineTime().Ticks - _ticksAtStart) / TimeSpan.TicksPerMillisecond)) : new TimeSpan(0, 0, 0, 0, (int)((_ticksNow - _ticksAtStart) / TimeSpan.TicksPerMillisecond)); } } public void Start() { _ticksAtStart = Microsoft.SPOT.Hardware.Utility.GetMachineTime().Ticks; IsRunning = true; } public void Stop() { if (!IsRunning) { throw new InvalidOperationException(); } _ticksNow = Microsoft.SPOT.Hardware.Utility.GetMachineTime().Ticks; IsRunning = false; } public void Resume() { if (IsRunning) { throw new InvalidOperationException(); } _ticksAtStart = Microsoft.SPOT.Hardware.Utility.GetMachineTime().Ticks - (_ticksNow - _ticksAtStart); IsRunning = true; } public void Reset() { _ticksAtStart = 0; _ticksNow = 0; IsRunning = false; } } }
- Netduino Forums
- → Viewing Profile: Posts: Drasive
- Privacy Policy