calling SwingWorker cancel in WindowClosing event handler
- From: yancheng.cheok@xxxxxxxxx
- Date: 31 Mar 2007 08:50:01 -0700
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???
}
.
- Follow-Ups:
- Re: calling SwingWorker cancel in WindowClosing event handler
- From: Knute Johnson
- Re: calling SwingWorker cancel in WindowClosing event handler
- From: Andrew Thompson
- Re: calling SwingWorker cancel in WindowClosing event handler
- Prev by Date: Re: Transparent window
- Next by Date: calling SwingWorker cancel in WindowClosing event handler
- Previous by thread: about converting an existing swing application to a plugin
- Next by thread: Re: calling SwingWorker cancel in WindowClosing event handler
- Index(es):
Relevant Pages
|