/// <summary> /// Registers a task as a child task in this container. /// </summary> /// <param name="task">A task to register as a subtask.</param> public void AddTask(AbstractTask task) { lock (this) { this.childTasks.Add(task); task.EstimationChanged += this.OnEstimationChanged; task.ProgressChanged += this.OnProgressChanged; task.CancellationToken = this.CancellationToken; task.StatusAccumulator = this.StatusAccumulator; task.Log = this.Log; this.UpdateEstimation(); } }
/// <summary> /// Initializes a new instance of the <see cref="EstimationChangedEventArgs"/> class. /// </summary> /// <param name="task">Task for which estimation has changed.</param> /// <param name="estimation">Current estimation (measured in abstract work units).</param> public EstimationChangedEventArgs(AbstractTask task, int estimation) { this.Estimation = estimation; this.Task = task; }
/// <summary> /// Sets the progress of a current sub-task and notifies everyone. /// </summary> /// <param name="operation">Sub-task for which it is needed to set estimation.</param> /// <param name="info">Human-readable information about operation to be displayed as a status in GUI.</param> /// <param name="progress">Current progress (in abstract work units) of a sub-task.</param> private void SetCurrentOperationProgress(AbstractTask operation, string info, int progress) => this.EmitCurrentOperationProgressChanged(operation, info, progress);
/// <summary> /// Sets the estimation of a current sub-task and notifies everyone. /// </summary> /// <param name="operation">Sub-task for which it is needed to set estimation.</param> /// <param name="estimation">Estimation (in abstract work units) of a sub-task.</param> private void SetCurrentOperationEstimation(AbstractTask operation, int estimation) => this.EmitCurrentOperationEstimationChanged(operation, estimation);
/// <summary> /// Helper that posts CurrentOperationEstimationChanged event into correct thread. /// </summary> /// <param name="task">Operation which estimation was changed.</param> /// <param name="estimation">Operation estimation value (measured in abstract work units).</param> private void EmitCurrentOperationEstimationChanged(AbstractTask task, int estimation) => this.Invoke(() => this.CurrentOperationEstimationChanged?.Invoke( this, new EstimationChangedEventArgs(task, estimation)));
/// <summary> /// Helper that posts CurrentOperationProgressChanged event into correct thread. /// </summary> /// <param name="task">Operation which progress was changed.</param> /// <param name="info">Human-readable information about operation to be displayed as a status in GUI.</param> /// <param name="progress">Operation progress value (measured in abstract work units).</param> private void EmitCurrentOperationProgressChanged(AbstractTask task, string info, int progress) => this.Invoke(() => this.CurrentOperationProgressChanged?.Invoke( this, new ProgressChangedEventArgs(task, info, progress)));
/// <summary> /// Initializes a new instance of the <see cref="ProgressChangedEventArgs"/> class. /// </summary> /// <param name="task">Task which progress has changed.</param> /// <param name="info">Current operation user-readable description.</param> /// <param name="progress">Current operation progress.</param> public ProgressChangedEventArgs(AbstractTask task, string info, int progress) { this.Task = task; this.Progress = progress; this.Info = info; }