Hallo,
I have implemented some long running processes with usage of RequestProcessor
and
ProgressHandle. I want to be able to cancel the processes via UI, so I use
requestProcessor = new RequestProcessor("ProcessData",1, true);
to create cancelable tasks:
RequestProcessor.Task task = requestProcessor.create(runnable);
and
ProgressHandleFactory.createHandle("blablabla", task);
to create the ProgressHandle.
In the runnable I try to detect the cancelation by
if (Thread.interrupted ())
as explained here:
https://netbeans.org/download/5_5/org-openide-util/org/openide/util/
RequestProcessor.html
but no interruption is detected if I press the cancel button in the progress-ui
after pressing
the "yes" button in the message window to allow cancelation.
I have also found
https://rubenlaguna.com/post/2010-01-18-cancellable-tasks-and-progress-indicators-netbeans-platform/
with the suggestion to use
Thread.sleep(0) (or any other blocking operation) inside the run() which should
result in
throwing an InterruptedException which I can catch. But also this exception is
never thrown
if I press the cancel button.
Some explaination about fireing of InterruptedException I have found here:
https://dzone.com/articles/interruptedexception-and
Any ideas?
best regards
Oliver