Questions tagged [cancellation]

Cancellation is paradigm that allows cooperatively canceling a running operation before it finishes.

Cancellation is paradigm that allows cooperatively canceling a running operation before it finishes.

In , cancellation is achieved using for signaling cancellation and a CancellationToken is used by the operation to check whether cancellation was requested.

712 questions
10
votes
5 answers

How to cancel an observable sequence

I have a very simple IObservable that acts as a pulse generator every 500ms: var pulses = Observable.GenerateWithTime(0, i => true, i => i + 1, i => i, i => TimeSpan.FromMilliseconds(500)) And I have a…
Ronald Wildenberg
  • 31,634
  • 14
  • 90
  • 133
10
votes
1 answer

Implementing cancellable syscalls in userspace

I'm working on implementing pthread cancellation on Linux without any of the "unpleasant behavior" (some might say bugs) discussed in some of my other recent questions. The Linux/glibc approach to pthread cancellation so far has been to treat it as…
R.. GitHub STOP HELPING ICE
  • 208,859
  • 35
  • 376
  • 711
10
votes
3 answers

What happens if a signal handler is invoked while at a cancellation point?

Suppose an application is blocked at a cancellation point, for example read, and a signal is received and a signal handler invoked. Glibc/NPTL implements cancellation points by enabling asynchronous cancellation for the duration of the syscall, so…
R.. GitHub STOP HELPING ICE
  • 208,859
  • 35
  • 376
  • 711
10
votes
3 answers

Task.Wait unexpected behavior in case of OperationCanceledException

Consider the following piece of code: CancellationTokenSource cts0 = new CancellationTokenSource(), cts1 = new CancellationTokenSource(); try { var task = Task.Run(() => { throw new OperationCanceledException("123", cts0.Token); }, cts1.Token); …
proman
  • 277
  • 2
  • 10
9
votes
1 answer

Snakemake hangs when cluster (slurm) cancelled a job

Maybe the answer is obvious for many, but I am quite surprised I could not find a question regarding this topic, which represents a major problem for me. I would greatly appreciate a hint! When submitting a job on a cluster managed by slurm, if the…
davide m
  • 91
  • 5
9
votes
2 answers

Task.Delay didn’t get canceled?

I am trying to build an interface for a game. The game runs for 1 minute. The GetStop method stops after 60 sec game. The play method starts the game and the quit method quit the game. Now ideally what I want is when I quit the game after 30…
9
votes
1 answer

Capturing CancelKeyPress to stop an async console app at a safe point

I'm working on a small utility console app, built in C# 7.1 (which has async Main support). The app takes one of several input commands and then starts a long-running process which iterates through tens of thousands of items, processing each. I want…
awj
  • 7,482
  • 10
  • 66
  • 120
9
votes
1 answer

.NET HttpClient - cancelled CancellationToken not cancelling request

I'm running into an issue with the .NET HttpClient class (.NET 4.5.1, System.Net.Http v4.0.0.0). I'm calling HttpClient.GetAsync, passing in a CancellationToken (as part of a Nuget package that abstracts calls between webservices). If the token has…
user677526
9
votes
4 answers

Acoustic echo cancellation in Java

I'm implementing a VOIP application that uses pure Java. There is an echo problem that occurs when users do not use headsets (mostly on laptops with built-in microphones). What currently happens The nuts and bolts of the VOIP application is just the…
Garg Unzola
  • 376
  • 1
  • 4
  • 9
9
votes
3 answers

NsoperationQueue Cancel all operations is not cancelled until it finishes the operation

In my view i have image view, the data for image view comes form Url, the images are around 1-3 MB . If the user Swipes then i want to load the next image, Every thing works fine if swiped slowly, But when i swiped Fastly I want to Cancel the…
siva krishna
  • 1,149
  • 2
  • 15
  • 23
9
votes
1 answer

Cancelling specific items in a dataflow pipeline

I am building a Dataflows pipeline whose job it is to process large files. Each file is parsed, analyzed, and rendered; but every file may take a different path through the pipeline, depending on what type of file it is. The user interface for this…
Bugmaster
  • 1,048
  • 9
  • 18
9
votes
1 answer

Techniques for exiting / cancelling while loops across threads: bool, ManualResetEvent or CancellationToken

I am writing a program that has a few threads, each with a while loop that runs until the user specifies it should stop. I thought of a few ways to exit out of the loops, and subsequently the threads, and have outlined these approaches…
8
votes
2 answers

How to cancel GetConsumingEnumerable() on BlockingCollection

In the following code I'm using the CancellationToken to wake up the GetConsumingEnumerable() when the producer is not producing and I want to break out of the foreach and exit the Task. But I dont see IsCancellationRequested being logged and my…
Spud
  • 243
  • 1
  • 2
  • 12
8
votes
2 answers

React.js tells you to cancel promises. Official Promises can't be cancelled. What am I supposed to do instead?

In order to prevent phantom updates to an unmounted React component, React tells you to cancel any pending promises on a component (such as promises for fetching additional data) when it unmounts. This is very easy to accomplish with Bluebird…
TheHans255
  • 2,059
  • 1
  • 19
  • 36
8
votes
1 answer

Abort AJAX request via CancellationToken in ASP.NET MVC

I have an ASP.NET MVC application that interacts with external resources and there is an operation which takes a lot of time. So in controller I have method like this [HttpPost] public async Task SomeMethod(..., CancellationToken…