IDaemonService Interface |
Namespace: SanteDB.Core.Services
The IDaemonService type exposes the following members.
Name | Description | |
---|---|---|
IsRunning |
Indicates whether the daemon service is running
| |
ServiceName |
Gets the service name
(Inherited from IServiceImplementation.) |
Name | Description | |
---|---|---|
Start |
Indicates the caller wishes to start the daemon service lifecycle
| |
Stop |
Indicates the caller wishes to stop the daemon service
|
Name | Description | |
---|---|---|
Started |
Fired when the daemon service has completed it start procedure.
| |
Starting |
Fired when the daemon service has commenced start but has not yet finished
| |
Stopped |
Fired when the daemon has completed its stop procedure
| |
Stopping |
Fired when the daemon service has commenced stop but has not yet been fully shut down.
|
In SanteDB (and OpenIZ) a daemon service is an actively executed service which is started on application host start and torn down/stopped on application context shutdown (or when initiated by a user).
The Start method is invoked on startup. It is expected that implementer of this class will raise the Starting event to signal to other services in the application context that this particular service is starting. Once the initialization process is complete, the implementation should call the Started event to signal this service has completed its necessary start, before returning true from the start method. This behavior allows chaining of dependent services together (i.e. don't start until after start of another service)
On service teardown the Stop method is called, again it is expected that implementers will raise Stopping and then Stopped
If the daemon also implements the .NET IDisposable interface, then the Dispose method is called after service shutdown.
public class HelloWorldDaemon : IDaemonService { public event EventHandler Starting; public event EventHandler Started; public event EventHandler Stopping; public event EventHandler Stopped; public bool Start() { this.Starting?.Invoke(this, EventArgs.Empty); Console.WriteLine("Hello World!"); this.Started?.Invoke(this, EventArgs.Empty); return true; } public bool Stop() { this.Stopping?.Invoke(this, EventArgs.Empty); Console.WriteLine("Goodbye World!"); this.Stopped?.Invoke(this, EventArgs.Empty); return true; } }