IJob Interface |
Namespace: SanteDB.Core.Jobs
The IJob type exposes the following members.
Name | Description | |
---|---|---|
CanCancel |
True if the job can be cancelled
| |
CurrentState |
Gets the current status of the job
| |
Description |
Gets the description of the job
| |
Id |
A unique identifier for this job
| |
LastFinished |
Gets the time the job last finished
| |
LastStarted |
Gets the time the job last started
| |
Name |
The name of the job
| |
Parameters |
Get the parameter definitions
|
public class HelloWorldJob : IJob { private bool m_cancelRequested = false; public Guid Id => Guid.NewGuid(); public string Name => "Hello World Job!"; public bool CanCancel => true; public IDictionary<String, Type> Parameters => null; public JobStateType CurrentState { get; private set; } public DateTime? LastStarted { get; private set; } public DateTime? LastFinished { get; private set; } public void Cancel() { this.m_cancelRequested = true; } public void Run(object sender, EventArgs e, object[] parameters) { try { this.CurrentState = JobStateType.Running; this.LastStart = DateTime.Now; this.m_cancelRequested = false; while(!this.m_cancelRequested) { Console.Writeline("Hello World!"); } if(this.m_cancelRequested) { this.CurrentState = JobStateType.Cancelled; } else { this.CurrentState = JobStateTime.Complete; } this.LastFinished = DateTime.Now; } catch(Exception e) { this.CurrentState = JobStateType.Aborted; } } }