Killing all threads.

  • Thread starter Thread starter Bob Day
  • Start date Start date
B

Bob Day

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.application does not seem to
kill running threads.

Somthing like:

Kill.AllThreads

would be perfect.

thansk!

Bob Day
 
* "Bob Day said:
Is there an easy way to kill from the main form all threads running ? Is [...]
Somthing like:

Kill.AllThreads

would be perfect.

Very brutal method (/not/ recommended):

\\\
Dim t As System.Threading.Thread
For Each t In System.Diagnostics.Process.GetCurrentProcess().Threads
t.Abort()
Next t
///
 
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
 
Cor said:
In the documentation is written , that threads can be aborted but not
direct killed.

So you have to wait a while to see it.

Me.Shoot(cow)
Thread.Sleep(5000)
If Not Me.Look(Direction.Everywhere, GetType(Cow)) Then
Me.Cry "booooooohhoooohoooo"
End If
 
Hi Armin,

I love to answer this
Me.Shoot(cow)
Thread.Sleep(5000)
If Not Me.Look(Direction.Everywhere, GetType(Cow)) Then
Me.Cry "booooooohhoooohoooo"
End If

Sorry I do not understand you,

:-)))

Cor
 
Back
Top