<commit_before>﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Mastersign.Tasks
{
    internal class TaskWatcher
    {
        public ITask Task { get; private set; }

        private List<ITask> _incompleteDependencies = new List<ITask>();

        public TaskWatcher(ITask task)
        {
            Task = task;
            _incompleteDependencies.AddRange(task.Dependencies);
            foreach (var dep in _incompleteDependencies)
            {
                dep.StateChanged += DependencyStateChangedHandler;
            }
            IsReady = _incompleteDependencies.Count == 0;
        }

        private void DependencyStateChangedHandler(object sender, PropertyUpdateEventArgs<TaskState> e)
        {
            var dep = (ITask)sender;
            var depState = e.NewValue;
            if (depState == TaskState.InProgress ||
                depState == TaskState.CleaningUp ||
                depState == TaskState.Canceled)
            {
                return;
            }
            var notify = false;
            lock (_incompleteDependencies)
            {
                if (_incompleteDependencies.Contains(dep))
                {
                    _incompleteDependencies.Remove(dep);
                    dep.StateChanged -= DependencyStateChangedHandler;
                    if (_incompleteDependencies.Count == 0)
                    {
                        IsReady = true;
                        notify = true;
                    }
                }
            }
            if (depState == TaskState.Obsolete)
            {<commit_msg>automatically setting depencies to obsolete when cancelling<commit_after>﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Mastersign.Tasks
{
    internal class TaskWatcher
    {
        public ITask Task { get; private set; }

        private List<ITask> _incompleteDependencies = new List<ITask>();

        public TaskWatcher(ITask task)
        {
            Task = task;
            _incompleteDependencies.AddRange(task.Dependencies);
            foreach (var dep in _incompleteDependencies)
            {
                dep.StateChanged += DependencyStateChangedHandler;
            }
            IsReady = _incompleteDependencies.Count == 0;
        }

        private void DependencyStateChangedHandler(object sender, PropertyUpdateEventArgs<TaskState> e)
        {
            var dep = (ITask)sender;
            var depState = e.NewValue;
            if (depState == TaskState.InProgress ||
                depState == TaskState.CleaningUp)
            {
                return;
            }
            var notify = false;
            lock (_incompleteDependencies)
            {
                if (_incompleteDependencies.Contains(dep))
                {
                    _incompleteDependencies.Remove(dep);
                    dep.StateChanged -= DependencyStateChangedHandler;
                    if (_incompleteDependencies.Count == 0)
                    {
                        IsReady = true;
                        notify = true;
                    }
                }
            }
            if (depState == TaskState.Canceled || depState == TaskState.Obsolete)
            {
{'fraction_non_alphanumeric': 0.07266009852216748, 'fraction_numerical': 0.0012315270935960591, 'mean_word_length': 1.4669703872437359, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4409943', 'n_tokens_mistral': 795, 'n_tokens_neox': 734, 'n_words': 162}