Top "Cancellationtokensource" questions

Provides a cancellation token in .NET for cooperative cancellation of asynchronous or long-running synchronous operations.

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
How to cancel a CancellationToken

I start a task, that start other tasks and so forth. Given that tree, if any task fails the result …

c# task-parallel-library cancellationtokensource
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
How to find out an object has disposed?

I have a multi-threaded application and a CancellationToken is used as a shared object. Every thread can trigger it to …

c# dispose cancellationtokensource
How to "sleep" until timeout or cancellation is requested in .NET 4.0

What's the best way to sleep a certain amount of time, but be able to be interrupted by a IsCancellationRequested …

c# .net-4.0 sleep cancellation cancellationtokensource
Cancelling an HttpClient Request - Why is TaskCanceledException.CancellationToken.IsCancellationRequested false?

Given the following code: var cts = new CancellationTokenSource(); try { // get a "hot" task var task = new HttpClient().GetAsync("http://www.…

c# .net async-await dotnet-httpclient cancellationtokensource
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
How to reset the CancellationTokenSource and debug the multithread with VS2010?

I have used CancellationTokenSource to provide a function so that the user can cancel the lengthy action. However, after the …

c# .net winforms debugging cancellationtokensource
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
How to combine TaskCompletionSource and CancellationTokenSource?

I have such code (simplified here) which awaits finishing task: var task_completion_source = new TaskCompletionSource<bool>(); observable.…

c# asynchronous async-await cancellationtokensource taskcompletionsource