What is “cancellationToken” in the TaskFactory.StartNew() used for?
http://msdn.microsoft.com/en-us/library/dd988458.aspx UPD : so, let's discuss this article then: http://msdn.microsoft.com/en-us/library/dd997396.aspx I've changed that code a little: static void Main() { var tokenSource2 = new CancellationTokenSource(); CancellationToken ct = tokenSource2.Token; var task = Task.Factory.StartNew(() => { // Were we already canceled? ct.ThrowIfCancellationRequested(); bool moreToDo = true; Thread.Sleep(5000); while (moreToDo) { // Poll on this property if you have to do // other cleanup before throwing. if (ct.IsCancellationRequested) { Console.WriteLine("exit")