Mercurial > pub > ImplabNet
comparison Implab/Components/IRunnable.cs @ 251:7c7e9ad6fe4a v3
Prerelease version of RunnableComponent
Added draft messaging interfaces
Added more more helpers to Xml/SerializationHelpers
| author | cin |
|---|---|
| date | Sun, 11 Feb 2018 00:49:51 +0300 |
| parents | 9f63dade3a40 |
| children | c52691faaf21 |
comparison
equal
deleted
inserted
replaced
| 250:9f63dade3a40 | 251:7c7e9ad6fe4a |
|---|---|
| 4 | 4 |
| 5 namespace Implab.Components { | 5 namespace Implab.Components { |
| 6 /// <summary> | 6 /// <summary> |
| 7 /// Interface for the component which performs a long running task. | 7 /// Interface for the component which performs a long running task. |
| 8 /// </summary> | 8 /// </summary> |
| 9 public interface IRunnable : IDisposable { | 9 /// <remarks> |
| 10 /// The access to the runnable component should be sequential, the | |
| 11 /// componet should support asynchronous completion of the initiated | |
| 12 /// operation but operations itself must be initiated sequentially. | |
| 13 /// </remarks> | |
| 14 public interface IRunnable { | |
| 10 /// <summary> | 15 /// <summary> |
| 11 /// Starts this instance | 16 /// Starts this instance |
| 12 /// </summary> | 17 /// </summary> |
| 18 /// <remarks> | |
| 19 /// This operation is cancellable and it's expected to move to | |
| 20 /// the failed state or just ignore the cancellation request, | |
| 21 /// </remarks> | |
| 13 void Start(CancellationToken ct); | 22 void Start(CancellationToken ct); |
| 14 | 23 |
| 15 /// <summary> | 24 /// <summary> |
| 16 /// Stops this instance and releases all resources, after the instance is stopped it is moved to Disposed state and can't be reused. | 25 /// Stops this instance and releases all resources, after the |
| 26 /// instance is stopped it is moved to Disposed state and | |
| 27 /// can't be reused. | |
| 17 /// </summary> | 28 /// </summary> |
| 29 /// <remarks> | |
| 30 /// If the componet was in the starting state the pending operation | |
| 31 /// will be requested to cancel. The stop operatin will be | |
| 32 /// performed only if the component in the running state. | |
| 33 /// </remarks> | |
| 18 void Stop(CancellationToken ct); | 34 void Stop(CancellationToken ct); |
| 19 | 35 |
| 20 Task<ExecutionState> Completion { get; } | 36 /// <summary> |
| 37 /// The result of the last started operation. This property reflects | |
| 38 /// only the result of the last started operation and therefore should | |
| 39 /// change only if a new operation is initiated. | |
| 40 /// </summary> | |
| 41 Task Completion { get; } | |
| 21 | 42 |
| 43 /// <summary> | |
| 44 /// Current state of the componenet | |
| 45 /// </summary> | |
| 22 ExecutionState State { get; } | 46 ExecutionState State { get; } |
| 23 | 47 |
| 48 /// <summary> | |
| 49 /// Event to monitor the state of the component. | |
| 50 /// </summary> | |
| 24 event EventHandler<StateChangeEventArgs> StateChanged; | 51 event EventHandler<StateChangeEventArgs> StateChanged; |
| 25 | 52 |
| 53 /// <summary> | |
| 54 /// The last error | |
| 55 /// </summary> | |
| 26 Exception LastError { get; } | 56 Exception LastError { get; } |
| 27 } | 57 } |
| 28 } | 58 } |
| 29 | 59 |
