Groups | Blog | Home
all groups > dotnet remoting > march 2007 >

dotnet remoting : ThreadAbortException fails to get thrown from thread making remoting call.


Howard Swope
3/14/2007 9:56:04 AM
I have a thread that is making a remoting call. Another thread calls to
abort this thread, which is supposed to fire a ThreadAbortException on the
thread that is making the remoting call. This does not happen.

Any thoughts?

--
Howard Swope [hswopeATtrafficDOTcom]
Software Engineer
Media Development
Traffic.com [http://www.traffic.com]

Howard Swope
3/14/2007 1:20:24 PM
Thanks for your response...

The way that I have gotten around this is just making the calls from an
AsyncDelegate and waiting for the return. This way the call is going out on
a threadpool thread and the thread that I want to abort is waiting for it to
return and it will throw the ThreadAbortException (I do cleanup in my
finally block).

[quoted text, click to view]

Goran Sliskovic
3/14/2007 3:51:00 PM

[quoted text, click to view]
....

Threads can be aborted only in certain states and at certain moments. If
thread is blocked in API call for example, it cannot be aborted by .NET
framework. You may resort to aborting through native windows API, however
this may lead to nasty consequences (if possible at all). I thnik that there
should be some resources on the internet about .NET aborting calls.

I also noticed that remoting threads cannot be aborted. Since it rarly
happens, I leave them hanging. However, you must ensure that you don't hold
any locks in the process...

Regards,
Goran

Goran Sliskovic
3/15/2007 12:51:01 AM
[quoted text, click to view]
....

Haven't tried that method, just make sure you don't starve the thread
pool. There could be some limit on number of threads allocated to thread
pool.

The problem I run into with remoting is that in case of connection
physically going down, remote call would hang forever in same cases
(timing issue, waiting for response from remote host). That call is
blocked in native windows api (recv on socket) and there is no way of
stopping it. Eventually I guess TCP keepalive timer would kick in and
tear down connection, but I've never waited that long to check. Anyway,
it's rare condition, so few "hanging" threads don't impact much.

Why do you have to abort?

Regards,
AddThis Social Bookmark Button