cancellation

SwingWorker: when exactly is called done method?

孤人 提交于 2019-11-27 20:35:43
Javadoc of the done() method of SwingWorker: Executed on the Event Dispatch Thread after the doInBackground method is finished. I've clues that it is not true in the case of canceled worker. Done is called in each case (normal termination or cancellation) but when cancelled it is not enqueued to the EDT, as it happens for normal termination. Is there some more precise analisis on when done is called in the case that a SwingWorker is cancelled? Clarification: this question is NOT on how to cancel a SwingWorker . Here it is assumed that the SwingWorker is cancelled in the right way. And it is

Aborting a long running task in TPL

感情迁移 提交于 2019-11-27 13:57:46
问题 Our application uses the TPL to serialize (potentially) long running units of work. The creation of work (tasks) is user-driven and may be cancelled at any time. In order to have a responsive user interface, if the current piece of work is no longer required we would like to abandon what we were doing, and immediately start a different task. Tasks are queued up something like this: private Task workQueue; private void DoWorkAsync (Action<WorkCompletedEventArgs> callback, CancellationToken

Getting the saved instruction pointer address from a signal handler

风格不统一 提交于 2019-11-27 00:57:49
问题 My question is somewhat different from others that have asked about fault addresses. I'm trying to implement a horrible hack to determine, from a signal handler, whether the signal interrupted a syscall or ordinary user code by inspecting the code at the saved instruction pointer and comparing it against the possible syscall entry instructions for the host architecture it's running on. This is part of implementing correct POSIX thread cancellation that does not suffer from the race condition

SwingWorker: when exactly is called done method?

杀马特。学长 韩版系。学妹 提交于 2019-11-26 22:57:20
问题 Javadoc of the done() method of SwingWorker: Executed on the Event Dispatch Thread after the doInBackground method is finished. I've clues that it is not true in the case of canceled worker. Done is called in each case (normal termination or cancellation) but when cancelled it is not enqueued to the EDT, as it happens for normal termination. Is there some more precise analisis on when done is called in the case that a SwingWorker is cancelled? Clarification: this question is NOT on how to

Cancellation with Future and Promise in Scala

不问归期 提交于 2019-11-26 20:57:22
问题 This is a followup to my previous question. Suppose I have a task, which executes an interruptible blocking call. I would like to run it as a Future and cancel it with failure method of Promise . I would like the cancel to work as follows: If one cancels the task before it finished I would like the task to finish "immediately", interrupting the blocking call if it has already started and I would like the Future to invoke onFailure . If one cancels the task after the task finished I would like

How to stop a DispatchWorkItem in GCD?

ぃ、小莉子 提交于 2019-11-26 09:02:10
问题 I am currently playing around with Grand Central Dispatch and discovered a class called DispatchWorkItem . The documentation seems a little incomplete so I am not sure about using it the right way. I created the following snippet and expected something different. I expected that the item will be cancelled after calling cancel on it. But the iteration continues for some reason. Any ideas what I am doing wrong? The code seems fine for me. @IBAction func testDispatchItems() { let queue =

How cancel the execution of a SwingWorker?

折月煮酒 提交于 2019-11-26 05:27:30
Currently I have two SwingWorker threads doing job on background. If an exception occurs, the method stop to work, but the thread still runnig. How I do to stop the execution and kill the thread of the doInBackground() if an exception occurs? this.cancel(true) don't destroy/close the thread. How can I achieve this? @Override protected Boolean doInBackground() throws Exception { try { while (true) { //some code here return true; } } catch (Exception e) { this.cancel(true); //<-- this not cancel the thread return false; } } I see these threads in the debug of Netbeans. 'AWT-EventQueue-0' em

Promise - is it possible to force cancel a promise

蓝咒 提交于 2019-11-26 01:39:54
问题 I use ES6 Promises to manage all of my network data retrieval and there are some situations where I need to force cancel them. Basically the scenario is such that I have a type-ahead search on the UI where the request is delegated to the backend has to carry out the search based on the partial input. While this network request (#1) may take a little bit of time, user continues to type which eventually triggers another backend call (#2) Here #2 naturally takes precedence over #1 so I would

Promise - is it possible to force cancel a promise

ぐ巨炮叔叔 提交于 2019-11-26 01:11:53
I use ES6 Promises to manage all of my network data retrieval and there are some situations where I need to force cancel them. Basically the scenario is such that I have a type-ahead search on the UI where the request is delegated to the backend has to carry out the search based on the partial input. While this network request (#1) may take a little bit of time, user continues to type which eventually triggers another backend call (#2) Here #2 naturally takes precedence over #1 so I would like to cancel the Promise wrapping request #1. I already have a cache of all Promises in the data layer

How cancel the execution of a SwingWorker?

妖精的绣舞 提交于 2019-11-26 01:09:32
问题 Currently I have two SwingWorker threads doing job on background. If an exception occurs, the method stop to work, but the thread still runnig. How I do to stop the execution and kill the thread of the doInBackground() if an exception occurs? this.cancel(true) don\'t destroy/close the thread. How can I achieve this? @Override protected Boolean doInBackground() throws Exception { try { while (true) { //some code here return true; } } catch (Exception e) { this.cancel(true); //<-- this not