using System; using System.ComponentModel; namespace Chernobyl.ComponentModel { /// /// An interface for working with instances that represent work being done /// by some code. This code is often doing the work asynchronously but /// not always. /// public interface ITask { /// /// Cancels the work being done but only if it has not been canceled /// already and the has not /// reached 100%. If cancellation is successful, the /// event will be raised. Note that, when the work being done is on /// another thread, it is possible that the work will finish just as /// this method is invoked. /// void Cancel(); /// /// True if the task has been canceled, false if otherwise. /// bool IsCanceled { get; } /// /// The percentage of work, from 0% to 100%, that has been completed on /// this task. If the task is Canceled (i.e. is /// invoked) the value of this property will be set to zero by this /// . /// int ProgressPercentage { get; } /// /// An event that is raised when the is invoked /// on this instance. Note that this event is only raised once, /// regardless of how many times is invoked. This /// event will not be invoked if the /// is at 100%. /// event EventHandler Canceled; /// /// An event that is raised when the progress of the task has changed. /// event ProgressChangedEventHandler ProgressChanged; } }