By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,088 Members | 1,326 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,088 IT Pros & Developers. It's quick & easy.

Unhandled handled exception in Catch line

P: n/a
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?

--
Nick

---------------------------------------------------------------
Please do not reply directly to me, but the entire newsgroup.
Any views expressed above are my own
Without predjudice
Jan 31 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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!

"Nick" <no****@nospam.com> wrote in message
news:u0*************@TK2MSFTNGP10.phx.gbl...
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?

--
Nick

---------------------------------------------------------------
Please do not reply directly to me, but the entire newsgroup.
Any views expressed above are my own
Without predjudice

Jan 31 '06 #2

P: n/a
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" <no****@nospam.com> wrote in message
news:Oe**************@TK2MSFTNGP15.phx.gbl...
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!

"Nick" <no****@nospam.com> wrote in message
news:u0*************@TK2MSFTNGP10.phx.gbl...
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?

--
Nick

---------------------------------------------------------------
Please do not reply directly to me, but the entire newsgroup.
Any views expressed above are my own
Without predjudice


Jan 31 '06 #3

P: n/a
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" <ni***@aslan.nospam.co.uk> wrote in message
news:el**************@TK2MSFTNGP10.phx.gbl... Hi Nick,

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" <no****@nospam.com> wrote in message
news:Oe**************@TK2MSFTNGP15.phx.gbl...
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!

"Nick" <no****@nospam.com> wrote in message
news:u0*************@TK2MSFTNGP10.phx.gbl...
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?

--
Nick

---------------------------------------------------------------
Please do not reply directly to me, but the entire newsgroup.
Any views expressed above are my own
Without predjudice



Jan 31 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.