The CancellationToken is a .NET struct that enables cooperative cancellation of synchronous or asynchronous methods.
Questions tagged [cancellation-token]
366 questions
-1
votes
2 answers
Closing a task and checking if its not running before starting a new one
I have an application, when a button is clicked, it starts a task which connects to a specific bluetooth device and then have a continuous stream of data coming in and going out. When the user clicks on the button again, I'd like it to check, if the…

Rikas
- 23
- 1
- 6
-1
votes
2 answers
Stop a long nested loop task
I need to stop a task from running when the user hits the escape key. The problem is the task is running a method like:
void Start(){
while(long loop){
while(!userEvent) System.Windows.Forms.Application.DoEvents();
for(another…

mjgalindo
- 856
- 11
- 26
-2
votes
1 answer
How to cancel task but let her to finish the chunk?
I have a program (.NET Core C#) that delete data from DB, for each account - deletes all the data related to the account.
I want to add an option to stop the program but finish the deletion for the person the program is on and then stop and exit.
I…

Xodya
- 1
- 1
-2
votes
1 answer
Cancel a task that running on thread in ASP.NET MVC using C#
How do i run this task in background and my other web stuff (Server API's) should work? and also cancelable on any point. Because my server is capable of run heavy operations and multi thread.
C#
[HttpPost]
[AsyncTimeout(30 * 60 *…

Kishan Choudhary
- 3
- 3
-2
votes
3 answers
Missing CancellationToken.WaitHandle.Set() or how to indicate that a task is complete
I have a function that makes periodic checks to a web page (using REST) and then waits for a final response, if it gets a "non-final" response it tries again.
void PeriodicallyCheckSomething()
{
Task.Run(() => {
var isTaskComplete =…

Brian Rice
- 3,107
- 1
- 35
- 53
-2
votes
1 answer
Create Class With Value Which Resets using Task.Delay()
I have some flags values in an C# windows service which I want to temporarily be able to change but that will automatically revert to some default value after a period of time. The bare bones of the class look something like this
public class…

Xedni
- 3,662
- 2
- 16
- 27