Mercurial > pub > ImplabNet
comparison Implab/Components/IRunnable.cs @ 250:9f63dade3a40 v3
Working on runnable component
author | cin |
---|---|
date | Thu, 01 Feb 2018 02:43:35 +0300 |
parents | 7d07503621fe |
children | 7c7e9ad6fe4a |
comparison
equal
deleted
inserted
replaced
249:d82909310094 | 250:9f63dade3a40 |
---|---|
1 using System; | 1 using System; |
2 using System.Threading; | |
3 using System.Threading.Tasks; | |
2 | 4 |
3 namespace Implab.Components { | 5 namespace Implab.Components { |
4 /// <summary> | 6 /// <summary> |
5 /// Interface for the component which performs a long running task. | 7 /// Interface for the component which performs a long running task. |
6 /// </summary> | 8 /// </summary> |
7 /// <remarks> | |
8 /// <para>The component also should implement <see cref="IDisposable"/> interface to be able to release used resources.</para> | |
9 /// <para>All methods of this interface must be a thread safe. If the operation is not applicable in the current state the | |
10 /// method should throw an exception and keep the current state unchanged.</para> | |
11 /// </remarks> | |
12 public interface IRunnable : IDisposable { | 9 public interface IRunnable : IDisposable { |
13 /// <summary> | 10 /// <summary> |
14 /// Starts this instance | 11 /// Starts this instance |
15 /// </summary> | 12 /// </summary> |
16 IPromise Start(); | 13 void Start(CancellationToken ct); |
17 | 14 |
18 /// <summary> | 15 /// <summary> |
19 /// 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. | 16 /// Stops this instance and releases all resources, after the instance is stopped it is moved to Disposed state and can't be reused. |
20 /// </summary> | 17 /// </summary> |
21 IPromise Stop(); | 18 void Stop(CancellationToken ct); |
19 | |
20 Task<ExecutionState> Completion { get; } | |
22 | 21 |
23 ExecutionState State { get; } | 22 ExecutionState State { get; } |
24 | 23 |
25 event EventHandler<StateChangeEventArgs> StateChanged; | 24 event EventHandler<StateChangeEventArgs> StateChanged; |
26 | 25 |