Unhandled handled exception in Catch line

N

Nick

Hi there,

This probably wont make much sense but I'm getting an unhandled
exception being thrown in the following line...

Try
While True
Redraw control as necessary
End While
Catch ex as Exception <<< Here!
End Try

This code is being run in a seperate thread, hence the eternal loop,
stopping of the thread is performed by aborting it, which has always worked
for me in the past. This exception is actually bubbling up to the
application_unhandledexception event pointing to the Catch line. Which
Doesn't really make sense does it??

I've tried moving the drawing code around several times but the whole
concept of an unhandled exception occuring in the Catch line confuses me a
little. Does anyone have any idea why this would happen?
 
N

Nick

Sorry I forgot to mention what the exception actually is!

ThreadAbortException - Thread was being aborted.

Which is the whole reason the catch block is there, to catch that one
exception!
 
N

Nick Hall

Hi Nick,

ThreadAbortException is a "special" exception; unless the
System.Thread.ResetAbort method is called the exception will be
automatically rethrown.

Generally speaking it is not a good idea to have "generic" catch block of
this style as it can cause underlying problems to be hidden. Its better to
deal with the exception you expect and let anything else fall through.

Hope this helps,

Nick Hall
Nick said:
Sorry I forgot to mention what the exception actually is!

ThreadAbortException - Thread was being aborted.

Which is the whole reason the catch block is there, to catch that one
exception!
 
N

Nick

Hi Nick,
ThreadAbortException is a "special" exception; unless the
System.Thread.ResetAbort method is called the exception will be
automatically rethrown.

That's very strange, I must say that I have never experienced this
before and I have quite a few controls using threads in this mannor. I just
tried a test application and put a resetabort call into the
threadabortexception handler and it gets rid of the problem, it's rather
strange how I havent come across this before?!

Oh the joys! Thank you so much for your help.

Nick.

Nick Hall said:
Generally speaking it is not a good idea to have "generic" catch block of
this style as it can cause underlying problems to be hidden. Its better
to deal with the exception you expect and let anything else fall through.

Hope this helps,

Nick Hall
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top