public virtual Job Run() { Invoke(); if (ContinueWith != null) { Task.Run(() => ContinueWith.RunAsync()); } return(this); }
public virtual async Task <Job> RunAsync() { var task = new Task <Job>(new Func <Job>(Invoke)); task.Start(); if (ContinueWith != null) { await task.ContinueWith(t => ContinueWith.RunAsync()); } //if (JobState==AutomatMachine.JobState.Successful && !IsContinuous) //{ // return this; //} //if (Action != null) //{ // var task = new Task(Action); // LastWorkDate = DateTime.Now; // NextWorkDate = DateTime.Now.AddMilliseconds(Interval); // task.Start(); // if (ContinueWith != null) // await task.ContinueWith(t => ContinueWith.RunAsync()); // await task; // NumberOfWorking++; //} await task; return(this); }