Hi -
I am writing a service which will check a process and its threads for
their state ( alive or dead ).
The process has 5 .net managed threads created using thread.start and
each have been assigned a name.
As in .net there is no way we can get the managed threads, I am
thinking of making a win32 call and check their status.
I need help with regards to which win32 api functions will help me to
get a list of threads ( not OS threads but the .net managed threads )
and to check their status ( thread.IsAlive ,something like that ).
How do i accomplish this. ?
If there is another way I can get the process and get its threads to
check their status,rather than going win32 it will be helpful.
thanks
BG 3 22164
<by******@gmail .com> wrote in message
news:11******** **************@ g49g2000cwa.goo glegroups.com.. . Hi -
I am writing a service which will check a process and its threads for their state ( alive or dead ).
The process has 5 .net managed threads created using thread.start and each have been assigned a name.
As in .net there is no way we can get the managed threads, I am thinking of making a win32 call and check their status.
Sure there is a way to get the managed threads state...
ProcessThread.T hreadState Property
Willy.
Hi -
ProcessThread collection gives me all the threads associated with the
process ( meaning all the OS threads as well ).
I have created 5 threads in my service using Thread.Start and also given a
name Thread.Name = "x".
when I do
Process [] proc = Process.GetProc essByName("MyPr ocess");
foreach ( ProcessThread thread in proc[0].Threads )
I get 30 threads that are executing. The thread state doesn't have IsAlive
property which System.Threadin g.Thread has.
System.Diagnost ics.ProcessThre ad and System.Threadin g.Thread are no way
related.
I hope you understand my question. I want to check whther my main threads
that I created for that process are alive or not. ( not the OS threads that
may or may not include my threads).
Also ProcessThread.T hread has Id property which System.Threadin g.Thread
doesn't. Pluse the Ids keep changing.
--
Bhavin Gandhi
Software Developer
Rockwell Automation
USA
"Willy Denoyette [MVP]" wrote: <by******@gmail .com> wrote in message news:11******** **************@ g49g2000cwa.goo glegroups.com.. . Hi -
I am writing a service which will check a process and its threads for their state ( alive or dead ).
The process has 5 .net managed threads created using thread.start and each have been assigned a name.
As in .net there is no way we can get the managed threads, I am thinking of making a win32 call and check their status.
Sure there is a way to get the managed threads state... ProcessThread.T hreadState Property
Willy.
Oh, but you asked about the Win32 api's to get the thread status, right?
Managed threads aren't known by the OS so there are no Win32 API's to get
the 'status' of a managed threads.
All managed threads are associated with an OS thread, but if you are only
interested in the IsAlive property of a few of your threads you will have to
store the reference to the thread object in an array (or an hashtable keyed
with the thread name for easy lookup).
From this array you can select a thread to query its IsAlive property.
Willy.
Just wonder who created the other 25 threads in your process.
"BGandhi" <BG*****@discus sions.microsoft .com> wrote in message
news:CE******** *************** ***********@mic rosoft.com... Hi -
ProcessThread collection gives me all the threads associated with the process ( meaning all the OS threads as well ).
I have created 5 threads in my service using Thread.Start and also given a name Thread.Name = "x".
when I do
Process [] proc = Process.GetProc essByName("MyPr ocess");
foreach ( ProcessThread thread in proc[0].Threads )
I get 30 threads that are executing. The thread state doesn't have IsAlive property which System.Threadin g.Thread has.
System.Diagnost ics.ProcessThre ad and System.Threadin g.Thread are no way related.
I hope you understand my question. I want to check whther my main threads that I created for that process are alive or not. ( not the OS threads that may or may not include my threads).
Also ProcessThread.T hread has Id property which System.Threadin g.Thread doesn't. Pluse the Ids keep changing.
-- Bhavin Gandhi Software Developer Rockwell Automation USA
"Willy Denoyette [MVP]" wrote:
<by******@gmail .com> wrote in message news:11******** **************@ g49g2000cwa.goo glegroups.com.. . > Hi - > > I am writing a service which will check a process and its threads for > their state ( alive or dead ). > > The process has 5 .net managed threads created using thread.start and > each have been assigned a name. > > As in .net there is no way we can get the managed threads, I am > thinking of making a win32 call and check their status. >
Sure there is a way to get the managed threads state... ProcessThread.T hreadState Property
Willy.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: WinstonSmith |
last post by:
Hallo everyone,
is there a way to get a list of all threads an application written in C#
uses?
Thanks in advance
Matthias
|
by: John Wood |
last post by:
Does anyone know how to enumerate the managed threads in the current
process?
Process.Threads gives you a list of ProcessThreads, but I want to somehow
get a list of the managed threads...
--
John Wood
Blog: http://spaces.msn.com/members/johnwood/
|
by: _BNC |
last post by:
Recently I had posted a query about intermittent problems with a
C++/Interop scheme (unmanaged C DLL wrapped in unmanaged C++,
wrapped in managed C++, all accessed by C#). The system works fine
when unstressed, but fails under stress.
Well...I just noticed short mention in Prosise's book, of all places,
re threading. He indicated that the behavior of unmanaged code within
managed threads is not predictable. I had thought that the...
|
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 T2, T4 and T5 are
already running.
Thanks,
Darian
|
by: R. Nachtsturm |
last post by:
Hi,
i have the problem that when i create a low priority background thread,
start it, and wait for it to finish that it does not seem to terminate even
after it is finished..
if i use performance monitoring to watch the actual thread count then it
never goes down.. everytime i create a thread it goes up by one.. even if i
abort the thread and set the thread object = nothing it still doesn't decrease
| |
by: Jon |
last post by:
My question is:
Can the Garbage Collector (GC) suspended a managed thread while it is executing native code.
The reason I am interested in this is that I have:
1) a native thread (N) that only executes native code,
2) a managed thread (M) that sometimes executes native code,
3) a critical section, that is shared by the native code portions of N & M.
And I what to know: Can N be suspend by the GC?
This would be true if the GC could...
|
by: Gunga Din |
last post by:
I must be missing it somehow...
I need to count the number of threads running, not just those started by my
application. Rather like the Task Manager, I would like to get the total
number of threads that are active.
What would be the most reliable way to obtain this number?
Thanks!
|
by: tshad |
last post by:
I need to find out how many threads a process has.
I have used ThreadPool.GetAvailableThreads and ThreadPool.GetMaxThreads, but
they both show 50 for worker threads and 100 for port threads. This stays
the same as each thread is opened up. After 3 or 4 are open the numbers are
the same.
How can I get the number of threads if this doesn't work?
Thanks,
|
by: darren |
last post by:
Hi
I have to write a multi-threaded program. I decided to take an OO
approach to it. I had the idea to wrap up all of the thread functions
in a mix-in class called Threadable. Then when an object should run
in its own thread, it should implement this mix-in class. Does this
sound like plausible design decision?
I'm surprised that C++ doesn't have such functionality, say in its
STL. This absence of a thread/object relationship in...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |