Killing threads

A

Amendra

hi,

I have a Parent child design of a multi threaded application in C#. My issue
is I want the parent class to be able abort or stop the child threads. I
tried abort from the parent, then the child goes to ThreadAbort Requested
state, and not abort state. But when I call the abort method from the child
Thread itself, it throws ThreadAbortException and aborts. Why is it, that
this does not work the same way when being aborted by the Childs parent.

I need the thread to abort in the way it aborts when being called abort by
the thread itself.

Any solution.

Thanks
Amendra
 
M

Miha Markic

Hi Amendra,

I think that, when Abort is invoked from outside, the thread waits for a
suitable moment to Abort...
From the .net help file:
"The thread is not guaranteed to abort immediately, or at all. This
situation can occur if a thread does an unbounded amount of computation in
the finally blocks that are called as part of the abort procedure, thereby
indefinitely delaying the abort. To ensure a thread has aborted, invoke a
Join method on the thread after calling Abort."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top