Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Changes to RGB LED animation thread to prevent a thread leak and properly stop animation #54
In StartRunningColors() it is possible for there to be a thread leak if it is called multiple times without calling Stop() outside the method (and also waiting at least the animation duration). Stop() would just set _running to false and immediately after it back to true so a currently running animation thread most often wouldn't be at the end of it's while loop at this time, so another thread will kick off and the current one will continue. This causes odd animation behavior and eventually crashes the Netduino. Because of a related race condition, if an animation is stopped and a color is set right after, the color that is set will most often get overridden by the animation thread turning off the LED when it completes.