Killing threads

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Amendra

    #1

    Killing threads

    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 ThreadAbortExce ption 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


  • Miha Markic

    #2
    Re: Killing threads

    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."
    --
    Miha Markic - RightHand .NET consulting & software development
    miha at rthand com

    "Amendra" <amendra@virtus a.com> wrote in message
    news:uT2Zc$NuDH A.620@TK2MSFTNG P10.phx.gbl...[color=blue]
    > hi,
    >
    > I have a Parent child design of a multi threaded application in C#. My[/color]
    issue[color=blue]
    > 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[/color]
    child[color=blue]
    > Thread itself, it throws ThreadAbortExce ption 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
    >
    >[/color]


    Comment

    Working...