view 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
line wrap: on
line source

using System;
using System.Threading;
using System.Threading.Tasks;

namespace Implab.Components {
    /// <summary>
    /// Interface for the component which performs a long running task.
    /// </summary>
    public interface IRunnable : IDisposable {
        /// <summary>
        /// Starts this instance
        /// </summary>
        void Start(CancellationToken ct);

        /// <summary>
        /// Stops this instance and releases all resources, after the instance is stopped it is moved to Disposed state and can't be reused.
        /// </summary>
        void Stop(CancellationToken ct);

        Task<ExecutionState> Completion { get; }

        ExecutionState State { get; }

        event EventHandler<StateChangeEventArgs> StateChanged;

        Exception LastError { get; }
    }
}