Click or drag to resize
IHeartbeatService Interface
A service that raises an event on a background thread every so-many minutes.

Namespace: VirtualRadar.Interface
Assembly: VirtualRadar.Interface (in VirtualRadar.Interface.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
public interface IHeartbeatService : ISingleton<IHeartbeatService>, 
	IDisposable

The IHeartbeatService type exposes the following members.

Properties
  NameDescription
Public propertySingleton
Gets the single instance of the class that should be used throughout the application.
(Inherited from ISingletonT.)
Top
Methods
  NameDescription
Public methodDispose
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
(Inherited from IDisposable.)
Public methodFastTickNow
Raises FastTick on a background thread.
Public methodSlowTickNow
Raises SlowTick on a background thread.
Public methodStart
Starts the timers.
Top
Events
  NameDescription
Public eventFastTick
Raised once every second or so.
Public eventSlowTick
Raised once every ten seconds or so.
Top
Remarks

The intention with this is to make it a bit easier to write tests for code that checks for program updates / new versions of files once every day or so. It can get complicated if the code that does the checking is using a real timer or is invoking code on a second thread.

If an object wants to periodically do some work then it hooks either SlowTick or FastTick on the object exposed by the Singleton property. These events are raised on a background thread so the object that hooks them does not have to get involved with maintaining a background thread or with periodically running a method on a background thread. However none of the Tick events are guaranteed to be raised exactly so-many seconds apart so the object that hooks them is expected to keep a track of the time that has elapsed since the last invocation of the event handler and make sure that they don't perform their periodic work before the requisite period of real time has elapsed.

Exceptions raised on the event handlers are currently logged but not pushed up to the GUI.

The Singleton version of the heartbeat service is started by the splash screen and is available to plugins in their Startup method. However if plugins want to maintain use their own instance of the heartbeat service they are welcome to do so - by doing this they can avoid blocking other objects that use the service. However if timely background processing is an issue for a plugin then perhaps the heartbeat service is not the best way of implementing it.

See Also