Re: Thread.Abort() vs. Unmanaged Code

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: David Levine (noSpamdlevineNNTP2_at_wi.rr.com)
Date: 09/21/04


Date: Tue, 21 Sep 2004 18:40:22 -0500

If you really need to kill the control and all its threads then your idea is
a good one. That allows you to use the isolation provided by the win32 OS
itself to prevent corruption of the .net process your own code runs in. If
you want to kill a thread in an unclean manner (e.g. using Win32's
TerminateThread from within .net) there are all kinds of problems that you
will run into if the process itself keeps running, so KillProcess is a
preferred mechanism.

"Christian Kesselheim via .NET 247" <anonymous@dotnet247.com> wrote in
message news:%23QXcJU9nEHA.2096@TK2MSFTNGP15.phx.gbl...
Hi!

Quite recently, I've been facing the situation of having to wrap up a
(buggy) third-party activex control in .NET in order to expose its
functionality via http webservices. After some unpleasant experiments
involving AppDomain's, Thread.Abort(), W32 TerminateThread(), I had
everything working exactly the way I wanted it (clean AppDomain unload in
case of an segfaults, etc), except for the rare case in which the OCX itself
decided to go for some endless loop and my thread never returned from
unmanaged code.

After spending some time investigating different newsgroups, etc, it occured
to me that there really was no way of terminating a thread within unmanaged
code in the current version of the .NET framework (1.1). Nevertheless, since
I'm not willing (nor able) to throw in the towel yet, I'm still hunting for
the best possible solution to my particular problem.

Do you think wrapping the nasty OCX into another instance of
System.Diagnostics.Process, handling all communication via .NET Remoting and
invoking Process.Kill when necessary would meet my needs, perhaps?

Thnx in advance. Regards,

Chris

--------------------------------
From: Christian Kesselheim

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>LhyLycsvCkGPlL89p7Dx8g==</Id>



Relevant Pages

  • Re: Linux machines dieing in swap storms
    ... it is tooo easy to kill your linux computer. ... which can sometimes run out of control. ... suddenly starts growing in memory usage until it uses up all available ... swap storm behaviour. ...
    (Linux-Kernel)
  • Re: Science Fiction and Fantasy
    ... the power to hurt or kill at will and no accountability to ... if you really can't control yourself from killing people every ...
    (rec.arts.sf.written)
  • Re: Whitefly infestation in Tonnel
    ... whitefly can be difficult to control - some people say impossible - because ... chemical pesticides to kill them, you have to spray very regularly to control a severe ... Encarsia is a small parasitic wasp which lays its eggs in the scales ...
    (uk.rec.gardening)
  • Re: No prosecutions over Menezes
    ... Kratos is fine - if they get it right and a genuine threat is ... I would have no problem with the police shooting to kill a genuine ... were losing control of the situation. ...
    (uk.legal)
  • Re: Call TerminateThread from Kernel32
    ... process, the only chance you have is to call the "TerminateThread", not ... modify or at last kill processes with "normal" tools (e.g. ... I was looking for API Programming in Loads of Newsgroups, ... OpenThreadAPI function, this returns a handle to the thread that you ...
    (microsoft.public.vb.winapi)