.NET Micro Framework: Threads

Turns out its pretty easy to spawn a new thread in the .NET Micro Framework. First thing's first: make sure you've included the threading namespace:

using System.Threading;

Next, create a function that you want the thread to run (like blinking the LED):

private static void BlinkLed()
    OutputPort statusLed = new OutputPort(Pins.ONBOARD_LED, false);
    // do forever
    while (true)
        // toggle LED state

Now you just need to spawn it:

public static void Main()
    // spawn thread
    new Thread(BlinkLed).Start();

    // do other stuff

And, done!