Killing all threads.

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

    Killing all threads.

    VS 2003, vb.net ...

    Is there an easy way to kill from the main form all threads running ? Is
    there a thread collection to iterate through to kill each one? I know each
    thread's name, so could I kill it via the name? The trick is I am not in
    any of these threads I am trying to kill. None of these threads on there
    own ever die (they are always running in the background).

    I think I could set up an array when the threads are started, and then go
    back to that array and iterate through it somehow, but I was looking for
    something simpler.

    In debug mode, closing the main form & exit.applicatio n does not seem to
    kill running threads.

    Somthing like:

    Kill.AllThreads

    would be perfect.

    thansk!

    Bob Day


  • Armin Zingler

    #2
    Re: Killing all threads.

    "Bob Day" <BobDay@TouchTa lk.net> schrieb[color=blue]
    > Somthing like:
    >
    > Kill.AllThreads
    >
    > would be perfect.[/color]


    System.Diagnost ics.Process.Get CurrentProcess. Threads



    --
    Armin




    Comment

    • Herfried K. Wagner [MVP]

      #3
      Re: Killing all threads.

      * "Bob Day" <BobDay@TouchTa lk.net> scripsit:[color=blue]
      > Is there an easy way to kill from the main form all threads running ? Is [...]
      > Somthing like:
      >
      > Kill.AllThreads
      >
      > would be perfect.[/color]

      Very brutal method (/not/ recommended):

      \\\
      Dim t As System.Threadin g.Thread
      For Each t In System.Diagnost ics.Process.Get CurrentProcess( ).Threads
      t.Abort()
      Next t
      ///

      --
      Herfried K. Wagner [MVP]
      <http://www.mvps.org/dotnet>

      Comment

      • Cor

        #4
        Re: Killing all threads.

        Hi Bob,

        In addition to Herfried and Armin,

        In the documentation is written , that threads can be aborted but not direct
        killed.

        So you have to wait a while to see it.

        I hope this helps,

        Cor


        Comment

        • Armin Zingler

          #5
          Re: Killing all threads.

          "Cor" <non@non.com> schrieb[color=blue]
          > In the documentation is written , that threads can be aborted but not
          > direct killed.
          >
          > So you have to wait a while to see it.
          >[/color]

          Me.Shoot(cow)
          Thread.Sleep(50 00)
          If Not Me.Look(Directi on.Everywhere, GetType(Cow)) Then
          Me.Cry "booooooohhoooo hoooo"
          End If


          --
          Armin




          Comment

          • Cor

            #6
            OT: Re: Killing all threads.

            Hi Armin,

            I love to answer this
            [color=blue]
            > Me.Shoot(cow)
            > Thread.Sleep(50 00)
            > If Not Me.Look(Directi on.Everywhere, GetType(Cow)) Then
            > Me.Cry "booooooohhoooo hoooo"
            > End If[/color]

            Sorry I do not understand you,

            :-)))

            Cor


            Comment

            • Bob Day

              #7
              Re: Killing all threads. Done

              Thanks!
              bob day
              "Bob Day" <BobDay@TouchTa lk.net> wrote in message
              news:%232lc4wI3 DHA.3916@TK2MSF TNGP11.phx.gbl. ..[color=blue]
              > VS 2003, vb.net ...
              >
              > Is there an easy way to kill from the main form all threads running ? Is
              > there a thread collection to iterate through to kill each one? I know[/color]
              each[color=blue]
              > thread's name, so could I kill it via the name? The trick is I am not in
              > any of these threads I am trying to kill. None of these threads on there
              > own ever die (they are always running in the background).
              >
              > I think I could set up an array when the threads are started, and then go
              > back to that array and iterate through it somehow, but I was looking for
              > something simpler.
              >
              > In debug mode, closing the main form & exit.applicatio n does not seem to
              > kill running threads.
              >
              > Somthing like:
              >
              > Kill.AllThreads
              >
              > would be perfect.
              >
              > thansk!
              >
              > Bob Day
              >
              >[/color]


              Comment

              Working...