IRunnable.cs
59 lines
| 2.0 KiB
| text/x-csharp
|
CSharpLexer
|
|
r152 | using System; | ||
|
|
r250 | using System.Threading; | ||
| using System.Threading.Tasks; | ||||
|
|
r152 | |||
| namespace Implab.Components { | ||||
|
|
r250 | /// <summary> | ||
| /// Interface for the component which performs a long running task. | ||||
|
|
r208 | /// </summary> | ||
|
|
r251 | /// <remarks> | ||
| /// The access to the runnable component should be sequential, the | ||||
| /// componet should support asynchronous completion of the initiated | ||||
| /// operation but operations itself must be initiated sequentially. | ||||
| /// </remarks> | ||||
| public interface IRunnable { | ||||
|
|
r203 | /// <summary> | ||
|
|
r208 | /// Starts this instance | ||
|
|
r203 | /// </summary> | ||
|
|
r251 | /// <remarks> | ||
| /// This operation is cancellable and it's expected to move to | ||||
| /// the failed state or just ignore the cancellation request, | ||||
| /// </remarks> | ||||
|
|
r250 | void Start(CancellationToken ct); | ||
|
|
r152 | |||
|
|
r203 | /// <summary> | ||
|
|
r251 | /// Stops this instance and releases all resources, after the | ||
| /// instance is stopped it is moved to Disposed state and | ||||
| /// can't be reused. | ||||
|
|
r203 | /// </summary> | ||
|
|
r251 | /// <remarks> | ||
| /// If the componet was in the starting state the pending operation | ||||
| /// will be requested to cancel. The stop operatin will be | ||||
| /// performed only if the component in the running state. | ||||
| /// </remarks> | ||||
|
|
r250 | void Stop(CancellationToken ct); | ||
|
|
r251 | /// <summary> | ||
| /// The result of the last started operation. This property reflects | ||||
| /// only the result of the last started operation and therefore should | ||||
| /// change only if a new operation is initiated. | ||||
| /// </summary> | ||||
| Task Completion { get; } | ||||
|
|
r152 | |||
|
|
r251 | /// <summary> | ||
| /// Current state of the componenet | ||||
| /// </summary> | ||||
|
|
r152 | ExecutionState State { get; } | ||
|
|
r251 | /// <summary> | ||
| /// Event to monitor the state of the component. | ||||
| /// </summary> | ||||
|
|
r205 | event EventHandler<StateChangeEventArgs> StateChanged; | ||
|
|
r251 | /// <summary> | ||
| /// The last error | ||||
| /// </summary> | ||||
|
|
r152 | Exception LastError { get; } | ||
| } | ||||
| } | ||||
