view Implab/Components/IInitializable.cs @ 262:f1696cdc3d7a v3 v3.0.8

Added IInitializable.Initialize() overload Added IRunnable.Start(), IRunnable.Start() overloads Fixed cancellation of the current operation when Stop() is called More tests
author cin
date Mon, 16 Apr 2018 02:12:39 +0300
parents 7c7e9ad6fe4a
children
line wrap: on
line source

using System;
using System.Threading;

namespace Implab.Components {
    /// <summary>
    /// Initializable components are created and initialized in two steps, first we have create the component,
    /// then we have to complete it's creation by calling an <see cref="Initialize()"/> method. All parameters needed
    /// to complete the initialization must be passed before the calling <see cref="Initialize()"/>
    /// </summary>
    public interface IInitializable {
        /// <summary>
        /// Completes initialization.
        /// </summary>
        /// <remarks>
        /// <para>
        /// Normally virtual methods shouldn't be called from the constructor, due to the incomplete object state, but
        /// they can be called from this method. This method is also usefull when we constructing a complex grpah
        /// of components where cyclic references may take place.
        /// </para>
        /// <para>
        /// In asyncronous patterns <see cref="Initialize()"/> can be called
        /// to start initialization and the <see cref="IRunnable.Completion"/>
        /// property can be used to track operation completion.
        /// </para>
        /// </remarks>
        void Initialize();
        void Initialize(CancellationToken ct);
    }
}