|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Evaluating threads in an applicationHow can I gain access to all the threads running in my application? I'm
looking for something like: Application.Threads.count Application.threads(item).IsAlive Application.threads(item).Name etc. -Jerry Jerry Spence1 wrote:
> How can I gain access to all the threads running in my application? First get a System.Diagnostics.Process by callingSystem.Diagnostics.Process.GetCurrentProcess. Then look in the ProcessThreadCollection returned from Process.Threads - this is a collection of ProcessThread objects. > I'm System.Diagnostics.Process.GetCurrentProcess.Threads.Count> looking for something like: > > Application.Threads.count > Application.threads(item).IsAlive Interrogate the .ThreadState of each ProcessState. There's more tothread state than alive or not alive... > Application.threads(item).Name Threads don't have names, they have a .Id of type Integer.-- Larry Lard Replies to group please
Show quote
Hide quote
"Larry Lard" <larryl***@hotmail.com> wrote in message Thanks Larrynews:1149842101.593841.325780@h76g2000cwa.googlegroups.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.Threads.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. > > -- > Larry Lard > Replies to group please > 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.Threads.Count it returns about 23 so there is more going on than I am interested in. -Jerry Jerry Spence1 wrote:
Show quoteHide quote > "Larry Lard" <larryl***@hotmail.com> wrote in message Well I must admit I have never done this kind of stuff, and it seems I> news:1149842101.593841.325780@h76g2000cwa.googlegroups.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.Threads.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.Threads.Count it returns about > 23 so there is more going on than I am interested in. 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
Threading Advice
Changing text in Report viewer SQL Express or MDB - opinions please stupid questions re: DatagridView Problem with EventLog ExecuteNonQuery Wierdness Reading - Parsing Records From An LDAP LDIF File In .Net? Visual Studio 2005 - Code Snippet Manager missing Cloning a RichTextBox Data Reader |
|||||||||||||||||||||||