Top "Cancellation-token" questions

Cancellation token in Task constructor: why?

Certain System.Threading.Tasks.Task constructors take a CancellationToken as a parameter: CancellationTokenSource source = new CancellationTokenSource(); Task t = new Task (/* …

c# .net-4.0 task-parallel-library cancellation-token
Using CancellationToken for timeout in Task.Run does not work

OK, my questions is really simple. Why this code does not throw TaskCancelledException? static void Main() { var v = Task.Run(() =&…

c# .net task-parallel-library cancellationtokensource cancellation-token
Default parameter for CancellationToken

I have some async code that I would like to add a CancellationToken to. However, there are many implementations where …

c# asynchronous task-parallel-library cancellation-token
How to reset a CancellationToken properly?

I have been playing round with the Async CTP this morning and have a simple program with a button and …

c# asynchronous async-await cancellationtokensource cancellation-token
Should we use CancellationToken with MVC/Web API controllers?

There are different examples for async controllers. Some of them use CancellationToken in method definition: public async Task<ActionResult&…

c# asp.net-mvc asp.net-web-api async-await cancellation-token
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/…

c# multithreading cancellation-token
NetworkStream.ReadAsync with a cancellation token never cancels

Here the proof. Any idea what is wrong in this code ? [TestMethod] public void TestTest() { var tcp = new TcpClient() { ReceiveTimeout = 5000, …

.net sockets .net-4.5 async-await cancellation-token
What is the use of passing CancellationToken to Task Class constructor?

Here is a sample code that creates a new task that simulates a long running process. There is nothing much …

c# .net multithreading cancellation-token
Why CancellationToken is separate from CancellationTokenSource?

I'm looking for a rationale of why .NET CancellationToken struct was introduced in addition to CancellationTokenSource class. I understand how …

c# multithreading task-parallel-library cancellationtokensource cancellation-token
Linking Cancellation Tokens

I use a cancellation token that is passed around so that my service can be shut down cleanly. The service …

c# .net cancellationtokensource cancellation-token