// depends // input public WorkTask(NamedTasks Tasks, string Name) : base(Tasks, Name, null) { this.Yield = (Task, Arguments) => { if (Task.HasActiveDependencies) { Console.WriteLine("blocked"); return(null); } var Commit = default(Action); //Console.WriteLine(Task + " before FetchInput"); this.FetchInput( Input => { Commit = this.YieldWork(this, Input); } ); //Console.WriteLine(Task + " after FetchInput"); return(delegate { if (Commit != null) { Commit(); } }); }; }
public NamedTask(NamedTasks Tasks, string Name, Func <NamedTask, string, Action> Yield) { if (Tasks == null) { throw new NotSupportedException("Tasks null"); } this.Tasks = Tasks; this.Name = Name; if (Yield != null) { this.Yield = Yield; } this.Tasks.Items = new NamedTask.ChainLink(this) { Link = this.Tasks.Items }; this.Context = Tasks.TasksContext.CreateSubdirectory(Name); this.Lock = new DirectoryInfo(Path.Combine(this.Context.FullName, "Lock")); this.CounterPath = Path.Combine(this.Context.FullName, "Counter"); }
//public event Action Tick; public SchedulerTask(NamedTasks Tasks, string Name, int Interval) : base(Tasks, Name, null) { this.Interval = Interval; this.Description = "Scheduler task is responsible for dispatching tasks on regular basis. Interval: " + Interval; this.Yield = (Task, Arguments) => { Console.WriteLine("Counter: " + this.Counter); ForkTasksWithInput(); Thread.Sleep(Interval); return(delegate { // tick complete. }); }; }