This basically does the same thing as the Blinky tutorial, but it uses a Timer object with a callback method to turn the LED on and off.
Here's the code. If you think of any cool variations, please share.
using System; using System.Threading; using Microsoft.SPOT; using Microsoft.SPOT.Hardware; using SecretLabs.NETMF.Hardware; using SecretLabs.NETMF.Hardware.Netduino; namespace BlinkyTimer { public class Program { const int blinkPeriod = 250; static bool ledState; static OutputPort led; public static void Main() { // Set the initial state of the LED to off (false). ledState = false; led = new OutputPort(Pins.ONBOARD_LED, ledState); // Create a System.Threading.Timer instance and pass it the timer callback method. Timer blinkTimer = new Timer( new TimerCallback(BlinkTimerCallback), null, blinkPeriod, blinkPeriod); Thread.Sleep(Timeout.Infinite); } public static void BlinkTimerCallback(Object obj) { // Invert the previous state of the LED. ledState = !ledState; // Set the LED to its new state. led.Write(ledState); } } }