Home Help Center

Abort thread in C#

acbellacbell Member Andrew BellOrganization: Iowa State UniversityProject: National Resources Inventory ✭✭
Hi,

I am creating a thread from my C# application which makes an ICE request to a server. In some cases, I abort the thread that I created. This appears to be causing an assertion failure in Outgoing.finished(BasicStream). I know aborting the thread is bad practice, and I can change my code, but I was wondering if someone can tell me what might be going on.

Thanks as always,

Comments

  • michimichi Member Michi HenningOrganization: Triodia TechnologiesProject: I have a passing interest in Ice :-) ✭✭✭
    The run time contains various assertions to make sure that its data structures are in a consistent state. If you abort a thread while it is inside the run time, you will simply mess up Ice's internal housekeeping in most cases--the assertion catches that just as intended.

    I'm afraid that you will have to change your code. The run time isn't designed to cope with threads disappearing without warning at unpredictable times (and I don't see how the run time could be designed to cope with that, even theoretically). The situation is much the same as with thread cancellation in C++: in general, you cannot use it because destructors will no longer run, making a complete mess of any invariants.

    Cheers,

    Michi.
Sign In or Register to comment.