This code example demonstrates the use of .NET’s Timers on a GHI Electronics FEZ board. If you are not familiar with timer’s – think of them as just a loop that polls every N seconds – on the Nth second it performs an action. We suggest referring to MSDN for further information.
This code is written in C# and assumes the development workstation has all required software installed.
using System;
using System.Threading;
using Microsoft.SPOT;
public class Program
{
static void RunMe(object o)
{
Debug.Print("From timer!");
}
public static void Main()
{
Timer MyTimer = new Timer(new TimerCallback(RunMe), null, 5000, 1000);
Debug.Print("The timer will fire in 5 seconds and then fire priodically every 1 second");
Thread.Sleep(Timeout.Infinite);
}
}
For more information on specific namespaces please refer to the following resources: