[Mono-dev] (Nevermind) Asp.net thread abort issue

Kornél Pál kornelpal at hotmail.com
Sun Oct 9 09:03:58 EDT 2005


Hi,

Some more information:

ThreadAbortException thrown by Thread.Abort() will be wrapped by a
TargetInvocationException when it was thrown inside Invoke() just like any
other exception just like any other exception. This is the expected and
correct behavour.

When usin invoke it can be a good practicle to rethrow the wrapped exception
inside TargetInvocationException that let's you handle the exception as
usual.

If you experience different behaviour in Class Library of Mono than in Class
Library of MS.NET, for example ThreadAbortException wrapped by a
TargetInvocationException instead of a pure ThreadAbortException then please
file a bug report.

Kornél

----- Original Message -----
From: "Kornél Pál" <kornelpal at hotmail.com>
To: "Matthijs ter Woord" <matthijsterwoord at gmail.com>; "Joshua Tauberer"
<tauberer at for.net>
Cc: <mono-devel-list at lists.ximian.com>
Sent: Sunday, October 09, 2005 2:49 PM
Subject: Re: [Mono-dev] (Nevermind) Asp.net thread abort issue


> Hi,
>
> This has no connection with TargetInvocationException. A thread is aborted
> using an exception when the exception reaches the top of the stack the
> thread will be aborted. ThreadAbortException is a special one as it will
> be
> rethrown even when you caught it unless you called Thread.ResetAbort().
> Note
> that however that ThreadAbortException will not be rethrown if there is
> another exception on the stack as in this case that exception can reach
> the
> top of the stack and the thread will be aborted. In addition this gives
> you
> the ability to catch that exception and handle it rather than being lost
> by
> replacing it with a ThreadAbortException. In the case you mentioned this
> exception is TargetInvocationException but it could be any other exception
> as well.
>
> Kornél
>
> ----- Original Message -----
> From: "Matthijs ter Woord" <matthijsterwoord at gmail.com>
> To: "Joshua Tauberer" <tauberer at for.net>
> Cc: <mono-devel-list at lists.ximian.com>
> Sent: Sunday, October 09, 2005 2:10 PM
> Subject: Re: [Mono-dev] (Nevermind) Asp.net thread abort issue
>
>
>> IMHO, TargetInvocationException is raised for EVERY exception raised by
>> the
>> Invoke() 'd method.
>>
>>
>>
>> ----- Original Message -----
>> From: "Joshua Tauberer" <tauberer at for.net>
>> Cc: <mono-devel-list at lists.ximian.com>
>> Sent: Sunday, October 09, 2005 2:04 PM
>> Subject: Re: [Mono-dev] (Nevermind) Asp.net thread abort issue
>>
>>
>>> Gonzalo Paniagua Javier wrote:
>>>   > Anyway, if you ever decide to catch ThreadAbortException anywhere in
>> the
>>> > asp.net pipeline, bear in mind that it's used also when the configured
>>> > timeout is reached.
>>>
>>> The timeout for what?
>>>
>>> This ThreadAbortException business is quite something to get a handle
>>> on.  For instance, if you abort the thread within a method called by
>>> reflection, when Invoke() finishes the exception is a
>>> TargetInvocationException and not a ThreadAbortException, confusing my
>>> catch clauses higher up.  Is that the right behavior?  It also doesn't
>>> do the usual automatic re-throwing of the ThreadAbortException after
>>> catch clauses, so the thread goes on if the exception is caught at any
>>> point.
>>>
>>> --
>>> - Joshua Tauberer
>>>
>>> http://taubz.for.net
>>>
>>> ** Nothing Unreal Exists **
>>>
>>>
>>> _______________________________________________
>>> Mono-devel-list mailing list
>>> Mono-devel-list at lists.ximian.com
>>> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>>
>>
>> _______________________________________________
>> Mono-devel-list mailing list
>> Mono-devel-list at lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>>
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>




More information about the Mono-devel-list mailing list