calling SwingWorker cancel in WindowClosing event handler



hello,

i realize that when after i call SwingWorker cancel and try to wait
until the task is really canceled (through SwingWorker.get), i will
get exception as stated in http://java.sun.com/docs/books/tutorial/uiswing/concurrency/cancel.html

Note: If get is invoked on a SwingWorker object after its background
task has been cancelled, java.util.concurrent.CancellationException is
thrown.

Hence, i was wondering after the CancellationException caught, when
the time the next statement is executed, does the task is really
cancelled?

thanks

private void formWindowClosing(java.awt.event.WindowEvent evt)
{
// TODO add your handling code here:
try
{
marketTask.cancel(false);
marketTask.get();
}
catch(InterruptedException exp) {
}
catch(java.util.concurrent.ExecutionException exp)
{
}
catch(java.util.concurrent.CancellationException exp)
{
}

// So, does market Task really cancelled???
}

.



Relevant Pages

  • calling SwingWorker cancel in WindowClosing event handler
    ... i realize that when after i call SwingWorker cancel and try to wait ... get exception as stated in http://java.sun.com/docs/books/tutorial/uiswing/concurrency/cancel.html ... catch(java.util.concurrent.ExecutionException exp) ...
    (comp.lang.java.gui)
  • calling SwingWorker cancel in WindowClosing event handler
    ... i realize that when after i call SwingWorker cancel and try to wait ... get exception as stated in http://java.sun.com/docs/books/tutorial/uiswing/concurrency/cancel.html ... catch(java.util.concurrent.ExecutionException exp) ...
    (comp.lang.java.gui)
  • Re: calling SwingWorker cancel in WindowClosing event handler
    ... i realize that when after i call SwingWorker cancel and try to wait ... catch(java.util.concurrent.ExecutionException exp) ... You will know that marketTask is canceled by checking the return value of cancel. ... Attempts to cancel execution of this task. ...
    (comp.lang.java.gui)
  • Re: threading.Event usage causing intermitent exception
    ... Unhandled exception in thread started by ... That's typical when the interpreter has torn so much of itself down ... checks without invoking threads as the key press gets "missed" ... etc. (I want to cancel with a single key-press with no "return" hit. ...
    (comp.lang.python)
  • Re: My application exits after handling an ApplicationException
    ... I did the less elegant thing of setting a flag when Cancel ... exception from ADO.NET. ... returned to its message loop, no problem, no early exit. ... > Hi Tad, ...
    (microsoft.public.dotnet.languages.vb)