I have a several tasks that are run in sequence; one after the other.
Task.Factory.StartNew(() => DoWork1())
.ContinueWith((t1) => DoWork2())
.ContinueWith(t2 => DoWork3());
I want to put this inside a loop so they run indefinitely (After DoWork3()
is done, go back to DoWork1()
. I tried putting inside a while loop, but the loop goes to the next iteration as soon the task is launched, creating a boatload of new tasks.
Would also be nice to have a way to exit condition to break out of the loop, maybe pass a cancellation token.
Thanks!