[Insight-developers] interrupting filter execution
Paul Koshevoy
koshevoy at sci.utah.edu
Tue Jul 18 15:28:20 EDT 2006
Perhaps I am grossly misunderstanding the way exceptions work, but
unless GenerateData throws the ProcessAborted exception, the code below
will not do a thing for me.
My UI runs in an entirely different thread, it never comes near this
try/catch block. If I throw ProcessAborted from the UI callback when the
user clicks the [Cancel] button, it will kill my UI because it will
never be caught by the try/catch block you've pointed out.
At least, that is my current understanding. Exceptions are propagated up
the function call stack, you can't push them down the stack (or
broadcast them across threads).
Paul.
Karthik Krishnan wrote:
> Make the UI Abort button throw an ProcessAborted exception. See class
> ProcessAborted in Common/itkExceptionObject.h .
>
> The ProcessObject updates its output data as follows:
>
> try
> {
> this->GenerateData();
> }
> catch( ProcessAborted & excp )
> {
> excp = excp;
> this->InvokeEvent( AbortEvent() );
> this->ResetPipeline();
> this->RestoreInputReleaseDataFlags();
> throw ProcessAborted(__FILE__,__LINE__);
> }
> catch( ExceptionObject& excp )
> {
> ......
>
>
> So you could write your code as
>
> try { filter->GenerateData(); }
> catch (ProcessAborted &) { // Put up some UI dialog to tell the user
> we aborted.. }
> catch ...
>
>
> -karthik
>
> Paul Koshevoy wrote:
>
>> Hi,
>>
>> I am working on a UI with an ITK 2.4.1 backend. The UI is multi threaded
>> -- image processing in the secondary thread, UI in the first thread.
>> Some of the ITK operations I have to carry out take a significant amount
>> of time -- an itk::ImageFileReader stage on a 411MB file can take a
>> while, and itk::DiscreteGaussianImageFilter may take a while as well. In
>> the UI I present the user with a dialog where the ITK process can be
>> canceled. I call AbortGenerateDataOn() to interrupt the ITK processes.
>> I've noticed (by means of itk::SimpleFilterWatcher) that
>> AbortGenerateDataOn() has no effect on the itk::ImageFileReader or
>> itk::DiscreteGaussianImageFilter.
>>
>> Am I using the correct API for aborting the filters? What is the correct
>> way to stop a filter?
>>
>> Thank you,
>> Paul.
>>
>> _______________________________________________
>> Insight-developers mailing list
>> Insight-developers at itk.org
>> http://www.itk.org/mailman/listinfo/insight-developers
>>
>>
>>
More information about the Insight-developers
mailing list