using System; using System.Threading.Tasks; namespace Swan.Threading { /// /// Defines a standard API to control background application workers. /// public interface IWorker { /// /// Gets the current state of the worker. /// WorkerState WorkerState { get; } /// /// Gets a value indicating whether this instance is disposed. /// /// /// true if this instance is disposed; otherwise, false. /// bool IsDisposed { get; } /// /// Gets a value indicating whether this instance is currently being disposed. /// /// /// true if this instance is disposing; otherwise, false. /// bool IsDisposing { get; } /// /// Gets or sets the time interval used to execute cycles. /// TimeSpan Period { get; set; } /// /// Gets the name identifier of this worker. /// string Name { get; } /// /// Starts execution of worker cycles. /// /// The awaitable task. Task StartAsync(); /// /// Pauses execution of worker cycles. /// /// The awaitable task. Task PauseAsync(); /// /// Resumes execution of worker cycles. /// /// The awaitable task. Task ResumeAsync(); /// /// Permanently stops execution of worker cycles. /// An interrupt is always sent to the worker. If you wish to stop /// the worker without interrupting then call the /// method, await it, and finally call the method. /// /// The awaitable task. Task StopAsync(); } }