By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,989 Members | 2,392 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,989 IT Pros & Developers. It's quick & easy.

Killing all threads.

P: n/a
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
Nov 20 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
"Bob Day" <Bo****@TouchTalk.net> schrieb
Somthing like:

Kill.AllThreads

would be perfect.

System.Diagnostics.Process.GetCurrentProcess.Threa ds

--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2

P: n/a
* "Bob Day" <Bo****@TouchTalk.net> scripsit:
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().Thr eads
t.Abort()
Next t
///

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #3

P: n/a
Cor
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
Nov 20 '05 #4

P: n/a
"Cor" <no*@non.com> schrieb
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
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #5

P: n/a
Cor
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
Nov 20 '05 #6

P: n/a
Thanks!
bob day
"Bob Day" <Bo****@TouchTalk.net> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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

Nov 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.