Пример #1
0
        protected override void HandleTask(TaskArgs e)
        {
            //Load preliminary data to parallelize each

            Logger.Logger.Get(this).Message(string.Format("Task is handled to {0} to load tids", GetType().Name));

            e.Tids = new List<int> { ++_tidCount, ++_tidCount, ++_tidCount };
            Console.WriteLine($"{GetType().Name} loaded the following tids {e.Tids.ConvertAll(t => t.ToString(CultureInfo.InvariantCulture)).Aggregate((i, j) => i + ", " + j)}");

            Succesor?.Handle(e);
        }
Пример #2
0
        protected override void HandleTask(TaskArgs e)
        {
            Console.WriteLine($"Task is handled to {GetType().Name} to parallelize the queueing for tids:{e.Tids.ConvertAll(t => t.ToString(CultureInfo.InvariantCulture)).Aggregate((i, j) => i + "," + j)}" );
            this._tasks.Clear();
            e.Tids.ForEach(t => _tasks.Add(new System.Threading.Tasks.Task(() => new Task(e.EnginType, t).Execute())));

            Console.WriteLine($"{GetType().Name} parallelized the queueing for tids:{e.Tids.ConvertAll(t => t.ToString(CultureInfo.InvariantCulture)).Aggregate((i, j) => i + "," + j)}");

            Parallel.ForEach(_tasks, t => t.Start());

            Succesor?.Handle(e);
        }
Пример #3
0
 protected abstract void HandleTask(TaskArgs e);
Пример #4
0
 public virtual void Handle(TaskArgs e)
 {
     _handler?.Invoke(e);
 }