Top "Cancellation-token" questions

Get Task CancellationToken

Can I get CancellationToken which was passed to Task constructor during task action executing. Most of samples look like this: …

c# .net multithreading cancellation-token
Terminate or exit C# Async method with "return"

I was new to the async-await method in C# 5.0, and I have few questions in my mind What is the …

c# asynchronous task-parallel-library async-await cancellation-token
Is default(CancellationToken) equivalent to CancellationToken.None?

Looking at the implementation of CancellationToken.None, it is simply returning default(CancellationToken). However, I see no reference in CancellationToken's …

.net linq ado.net cancellation-token
Correct use of CancellationToken

This is my situation: private CancellationTokenSource cancellationTokenSource; private CancellationToken cancellationToken; public IoTHub() { cancellationTokenSource = new CancellationTokenSource(); cancellationToken = cancellationTokenSource.Token; receive(); } private …

c# cancellationtokensource cancellation-token
GetResponseAsync does not accept cancellationToken

It seems that GetResponseAsync does not accept cancellationToken in Async/Await. So the question is how can I cancel the …

c# httpwebrequest async-await httpwebresponse cancellation-token
TaskCanceledException when calling Task.Delay with a CancellationToken in an keyboard event

I am trying to delay the processing of a method (SubmitQuery() in the example) called from an keyboard event in …

c# asynchronous windows-runtime cancellationtokensource cancellation-token
Should I always add CancellationToken to my controller actions?

Is this a good practice to always add CancellationToken in my actions no matter if operation is long or not? …

c# asp.net-core asp.net-core-mvc asp.net-core-webapi cancellation-token
Can i cancel StreamReader.ReadLineAsync with a CancellationToken?

When I cancel my async method with the following content by calling the Cancel() method of my CancellationTokenSource, it will …

c# .net asynchronous cancellation-token
Stopping a Thread, ManualResetEvent, volatile boolean or cancellationToken

I have a Thread (STAThread) in a Windows Service, which performs a big amount of work. When the windows service …

c# multithreading cancellation cancellation-token
Is catching TaskCanceledException and checking Task.Canceled a good idea?

There are some people on my team who really love coding with async Task. And sometimes they like to use …

c# .net task-parallel-library task cancellation-token