using System;
namespace Implab.Components {
///
/// Interface for the component which performs a long running task.
///
///
/// The component also should implement interface to be able to release used resources.
/// All methods of this interface must be a thread safe. If the operation is not applicable in the current state the
/// method should throw an exception and keep the current state unchanged.
///
public interface IRunnable : IDisposable {
///
/// Starts this instance
///
IPromise Start();
///
/// Stops this instance, after the instance is stopped it can move to Failed, Ready or Disposed state, in case with the last it can't be reused.
///
IPromise Stop();
ExecutionState State { get; }
event EventHandler StateChanged;
Exception LastError { get; }
}
}