A heartbeat is a periodic event that tells you that your application is running. In this example the heartbeat is implemented by a static "heartbeat" class which has a "beat" event that fires every second.
The beat is passed on to any listeners that have been attached to the heartbeat. You can do this by adding listeners to the application configuration e.g.:-
Code:
<configSections>
<section name ="heartbeatSettings"
type="Monitoring.HeartbeatCustomConfigSection, Monitoring,
Version=1.0.0.0,Culture=neutral,PublicKeyToken=null"/>
</configSections>
<!-- ... -->
<heartbeatSettings>
<heartbeats>
<clear />
<add Name="HeartbeatTrace"
Type="Monitoring.TraceHeartbeatMonitor, Monitoring,
Version=1.0.0.0,Culture=neutral,PublicKeyToken=null" />
<add Name="HeartbeatTraceTwo"
Type="Monitoring.TraceHeartbeatMonitor, Monitoring,
Version=1.0.0.0,Culture=neutral,PublicKeyToken=null"
InitData="foo" />
</heartbeats>
</heartbeatSettings>
And then the only thing you need to do is to ask the heartbeat class to read its listeners collection from the configuration file by:-
Code:
Monitoring.Heartbeat.ResetListensersFromConfig();
You can create your own listener - to send heartbeats over the network or have a beating icon in the tray or what ever by inheritting from HeartbeatListenerBase