IRunnable.cs
52 lines
| 1.7 KiB
| text/x-csharp
|
CSharpLexer
cin
|
r152 | using System; | ||
cin
|
r250 | using System.Threading; | ||
using System.Threading.Tasks; | ||||
cin
|
r152 | |||
namespace Implab.Components { | ||||
cin
|
r250 | /// <summary> | ||
/// Interface for the component which performs a long running task. | ||||
cin
|
r208 | /// </summary> | ||
cin
|
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 { | ||||
cin
|
r203 | /// <summary> | ||
cin
|
r208 | /// Starts this instance | ||
cin
|
r203 | /// </summary> | ||
cin
|
r251 | /// <remarks> | ||
/// This operation is cancellable and it's expected to move to | ||||
/// the failed state or just ignore the cancellation request, | ||||
/// </remarks> | ||||
cin
|
r250 | void Start(CancellationToken ct); | ||
cin
|
r152 | |||
cin
|
r203 | /// <summary> | ||
cin
|
r251 | /// Stops this instance and releases all resources, after the | ||
/// instance is stopped it is moved to Disposed state and | ||||
/// can't be reused. | ||||
cin
|
r203 | /// </summary> | ||
cin
|
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> | ||||
cin
|
r250 | void Stop(CancellationToken ct); | ||
cin
|
r251 | /// <summary> | ||
cin
|
r256 | /// Current state of the componenet, dynamically reflects the current state. | ||
cin
|
r251 | /// </summary> | ||
cin
|
r152 | ExecutionState State { get; } | ||
cin
|
r251 | /// <summary> | ||
/// Event to monitor the state of the component. | ||||
/// </summary> | ||||
cin
|
r205 | event EventHandler<StateChangeEventArgs> StateChanged; | ||
cin
|
r251 | /// <summary> | ||
/// The last error | ||||
/// </summary> | ||||
cin
|
r152 | Exception LastError { get; } | ||
} | ||||
} | ||||