IHeartbeatService Interface |
Namespace: VirtualRadar.Interface
The IHeartbeatService type exposes the following members.
Name | Description | |
---|---|---|
Singleton |
Gets the single instance of the class that should be used throughout the application.
(Inherited from ISingletonT.) |
Name | Description | |
---|---|---|
Dispose | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. (Inherited from IDisposable.) | |
FastTickNow |
Raises FastTick on a background thread.
| |
SlowTickNow |
Raises SlowTick on a background thread.
| |
Start |
Starts the timers.
|
Name | Description | |
---|---|---|
FastTick |
Raised once every second or so.
| |
SlowTick |
Raised once every ten seconds or so.
|
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.