ThreadAbortException and Unmanaged Code

As you are probably aware Thread.Abort() raises a ThreadAbortException in the thread on which it is invoked, to begin the process of terminating the thread.

Please note that if Abort is called on a managed thread while it is executing unmanaged code, a ThreadAbortException is not thrown until the thread returns to managed code. That is also true when performing a COM Interop or P-Invoke. However if you have a ServicedComponent, the exception is received by the thread inside the component as expected. For instance if you are in an ASP.NET application and a timeout is occurred (timeout is communicated in terms of a ThreadAbortException) the exception is raised inside the component.