robotdotnet / WPILib

DotNet implementation of WPILib for FIRST Robotics Competition (FRC)
27 stars 8 forks source link

Need a better delay #40

Closed ThadHouse closed 8 years ago

ThadHouse commented 9 years ago

Thread.Sleep is not accurate enough. I was seeing between 2-7 ms of difference, even for long running delays. In https://github.com/robotdotnet/robotdotnet-wpilib/commit/96e965999885a12db3bd11d9c353ddefaf157243 I implemented one I have used before, where it delays up to 50ms before the needed time, and then runs a busy loop. I'll try and look for a way to precisely sleep without a busy loop, but for now it seems to work, and doesn't seem to be causing issues.

ThadHouse commented 8 years ago

I got a better one in. There's no better way to do it without a busy loop, however it spins for at max 12 ms. Which is much better.