A helper class library for .NET Micro Framework applications that need a regular timer.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



If your (.NET Micro Framework) application needs a regular, heartbeat-like event to function, MicroHeartBeat is for you. Set a period for the timer to trigger, add an event handler, and you're good to go.

This helper class was originally created for the AgentIntervals app. It's essentially just a wrapper around the stock Timer class, but with several methods to add useful functionality.

Quick Start

Include the contents of the bin/Release folder in your project, and add a reference to MicroHeartBeat.dll. Alternatively, just drop HeartBeat.cs in your project.

Example Usage

public class ExampleClass
	private static HeartBeat _heartBeat;
	public static void Main()
		// Events will trigger every 500 ms.
		_heartBeat = new HeartBeat(500);
		_heartBeat.OnHeartBeat += HeartBeatEventHandler;
	private static void HeartBeatEventHandler(object sender, EventArgs e)
		// Include your logic here!


HeartBeat(int period): construct a new HeartBeat that fires events every period milliseconds apart.

void Start(): begins the heartbeat immediately.

void Start(int delay): waits delay milliseconds, then begins the heartbeat.

void Stop(): stops the heartbeat.

bool Toggle(): if the heartbeat is running, stops it and returns false; if it is stopped, starts it immediately and returns true.

bool Toggle(int delay): same as Toggle(), but will wait delay milliseconds before starting the heartbeat.

void Reset(): stops and restarts the heartbeat.

void Reset(int delay): stops the heartbeat, waits delay milliseconds, then starts it again.

void ChangePeriod(int period): changes the heartbeat to trigger every period milliseconds instead. If the heartbeat is running, stops and starts it again.

##License MicroHeartBeat is available under the MIT License.