TaskFactory.StartNew() creates a new Task, starts it and then returns it. I suppose that it is safe to assume that the following code will always work (since it was taken from MSDN):
Task.Factory.StartNew(() => Console.WriteLine("first"))
.ContinueWith(antecendent => Console.WriteLine("second"));
How does this work? How can I be assured that the task hasn't been started (or even completed) before .ContinueWith()
is called?