473,324 Members | 2,248 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Evaluating threads in an application

How 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
Jun 9 '06 #1
3 1495

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.

--
Larry Lard
Replies to group please

Jun 9 '06 #2

"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.

--
Larry Lard
Replies to group please


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.

-Jerry
Jun 11 '06 #3

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

Jun 12 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Gabriele Bartolini | last post by:
Hi, I am writing an application in C++ on Linux, using threads (this is my first experience with pthreads). The application itself is fine, it is just that I wanted to handle asynchronous...
2
by: Jagadish | last post by:
Hi, My application requires to create a few threads on the occurance of an event E1 and the same threads need to be aborted on the occurance of another event E2. Iam not using .Net thread pool...
1
by: Paul Fi | last post by:
I have some confusions about the two, is it possible to create threads inside a particular domain and have other threads created in another domain or do we create threads that will manipulate app...
6
by: news.microsoft.com | last post by:
I have a very multi-threaded Windows Forms application. There are many BeginInvoke calls, as well as Thread/ThreadStarts. My issue is that when I quit my application there are often threads...
6
by: RahimAsif | last post by:
Hi guys, I would like some advice on thread programming using C#. I am writing an application that communicates with a panel over ethernet, collects data and writes it to a file. The way the...
2
by: Tumurbaatar S. | last post by:
ASP.NET QuickStart Tutorial says that: .... ASP.NET maintains a pool of HttpApplication instances over the course of a Web application's lifetime. ASP.NET automatically assigns one of these...
4
by: MSDousti | last post by:
Hi I have written a VB .NET app, which uses several threads. I thought that when the user closes the main window (when MainForm.closed event occures, and I call application.exit) all running...
10
by: Darian | last post by:
Is there a way to find all the thread names that are running in a project? For example, if I have 5 threads T1, T2, T3, T4, T5...and T2, T4, and T5 are running...I want to be able to know that...
6
by: Alexander Walker | last post by:
Hello Is it inefficient to create an application that has many threads that individually may do a small amount of work over a given period of time as opposed to an application that has a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.