Jerry Spence1 wrote:
"Larry Lard" <la*******@hotmail.com> wrote in message
news:11**********************@h76g2000cwa.googlegr oups.com...
Jerry Spence1 wrote: How can I gain access to all the threads running in my application?
First get a System.Diagnostics.Process by calling
System.Diagnostics.Process.GetCurrentProcess.
Then look in the ProcessThreadCollection returned from Process.Threads
- this is a collection of ProcessThread objects.
I'm
looking for something like:
Application.Threads.count
System.Diagnostics.Process.GetCurrentProcess.Threa ds.Count
Application.threads(item).IsAlive
Interrogate the .ThreadState of each ProcessState. There's more to
thread state than alive or not alive...
Application.threads(item).Name
Threads don't have names, they have a .Id of type Integer.
Thanks Larry
Not being able to get at the thread names is a problem. I am trying to
monitor the state of the threads in my project. How can I identify each
thread? I have created about 6 threads (and know their names) but when I do
System.Diagnostics.Process.GetCurrentProcess.Threa ds.Count it returns about
23 so there is more going on than I am interested in.
Well I must admit I have never done this kind of stuff, and it seems I
led you astray somewhat. It turns out there isn't necessarily aone to
one relationship between Thread objects (the things we create and
manipulate) and the actual OS level threads (as reported to us by
Diagnostics), so this is the wrong approach.
It looks like if you want to track your Thread objects properly, you
have to do it yourself, with an app-wide collection (with thread-safe
access, of course... possibly by wrapping it in something that mediates
access)
--
Larry Lard
Replies to group please