toGet Alive Thread Counts

G

Gopal Prabhakaran

Hi Guys

How to Get the alive Thread Count.

Sample code :

using System;
using System.Threading;

namespace threadSample

{

/// <summary>

/// Summary description for ThreadsCollection.

/// </summary>

public class ThreadsCollection
{
private Thread testThread;
public ThreadsCollection()

{

//

// TODO: Add constructor logic here

//

}

static void Main(string[] args)
{
s.threadsStart();
Console.WriteLine(s.testThread.Name.ToString());
}

private void threadsStart()

{

for(int i=0;i<3;i++)

{

testThread = new Thread(new ThreadStart(this.threadWorker));

testThread.Name = "Prabharkan" + i;

this.testThread.Start();

}

}

private void threadWorker()

{

while(true)

{

}

}

}

Now I want to get total number thread running with name

Pls help me to find out a way

(Without dumpping all the started threads in arraylist...)
 
N

Nicholas Paldino [.NET/C# MVP]

Gopal,

I am not quite sure what you mean. You say you want to get all of the
running threads with the same, but with the same what?
 
G

Gopal Prabhakaran

Dear Nicholas Paldino

I have created 5 threads with unique names,

I want the know the status of the threads created by me

Is there any ThreadCollection...???

Thnax
Prabharkan.G

Nicholas Paldino said:
Gopal,

I am not quite sure what you mean. You say you want to get all of the
running threads with the same, but with the same what?


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Gopal Prabhakaran said:
Hi Guys

How to Get the alive Thread Count.

Sample code :

using System;
using System.Threading;

namespace threadSample

{

/// <summary>

/// Summary description for ThreadsCollection.

/// </summary>

public class ThreadsCollection
{
private Thread testThread;
public ThreadsCollection()

{

//

// TODO: Add constructor logic here

//

}

static void Main(string[] args)
{
s.threadsStart();
Console.WriteLine(s.testThread.Name.ToString());
}

private void threadsStart()

{

for(int i=0;i<3;i++)

{

testThread = new Thread(new ThreadStart(this.threadWorker));

testThread.Name = "Prabharkan" + i;

this.testThread.Start();

}

}

private void threadWorker()

{

while(true)

{

}

}

}

Now I want to get total number thread running with name

Pls help me to find out a way

(Without dumpping all the started threads in arraylist...)


--

Thanx
Gopal Prabhakaran

--
"Sucess Comes To Those Who Dare To Dream"

Thanx
Gopal Prabhakaran
 
N

Nicholas Paldino [.NET/C# MVP]

Gopal,

There is not. If you created the threads, and want to keep track of
them, then you will have to do it yourself. The easiest way to do this is
to have a static method that you use to create your threads and then have a
property that is exposed which will give you the details about the threads
created through that method.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Gopal Prabhakaran said:
Dear Nicholas Paldino

I have created 5 threads with unique names,

I want the know the status of the threads created by me

Is there any ThreadCollection...???

Thnax
Prabharkan.G

message news:[email protected]...
Gopal,

I am not quite sure what you mean. You say you want to get all of the
running threads with the same, but with the same what?


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Gopal Prabhakaran said:
Hi Guys

How to Get the alive Thread Count.

Sample code :

using System;
using System.Threading;

namespace threadSample

{

/// <summary>

/// Summary description for ThreadsCollection.

/// </summary>

public class ThreadsCollection
{
private Thread testThread;
public ThreadsCollection()

{

//

// TODO: Add constructor logic here

//

}

static void Main(string[] args)
{
s.threadsStart();
Console.WriteLine(s.testThread.Name.ToString());
}

private void threadsStart()

{

for(int i=0;i<3;i++)

{

testThread = new Thread(new ThreadStart(this.threadWorker));

testThread.Name = "Prabharkan" + i;

this.testThread.Start();

}

}

private void threadWorker()

{

while(true)

{

}

}

}

Now I want to get total number thread running with name

Pls help me to find out a way

(Without dumpping all the started threads in arraylist...)


--

Thanx
Gopal Prabhakaran

--
"Sucess Comes To Those Who Dare To Dream"

Thanx
Gopal Prabhakaran
 
G

Gopal Prabhakaran

Dear Nicholas Paldino

Thanx for ur Timing Help ,Thanx a Lot....

Can u Pls tell me about - What is ProcessThreadCollection?

Nicholas Paldino said:
Gopal,

There is not. If you created the threads, and want to keep track of
them, then you will have to do it yourself. The easiest way to do this is
to have a static method that you use to create your threads and then have a
property that is exposed which will give you the details about the threads
created through that method.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Gopal Prabhakaran said:
Dear Nicholas Paldino

I have created 5 threads with unique names,

I want the know the status of the threads created by me

Is there any ThreadCollection...???

Thnax
Prabharkan.G

message news:[email protected]...
Gopal,

I am not quite sure what you mean. You say you want to get all of the
running threads with the same, but with the same what?


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


Hi Guys

How to Get the alive Thread Count.

Sample code :

using System;
using System.Threading;

namespace threadSample

{

/// <summary>

/// Summary description for ThreadsCollection.

/// </summary>

public class ThreadsCollection
{
private Thread testThread;
public ThreadsCollection()

{

//

// TODO: Add constructor logic here

//

}

static void Main(string[] args)
{
s.threadsStart();
Console.WriteLine(s.testThread.Name.ToString());
}

private void threadsStart()

{

for(int i=0;i<3;i++)

{

testThread = new Thread(new ThreadStart(this.threadWorker));

testThread.Name = "Prabharkan" + i;

this.testThread.Start();

}

}

private void threadWorker()

{

while(true)

{

}

}

}

Now I want to get total number thread running with name

Pls help me to find out a way

(Without dumpping all the started threads in arraylist...)


--

Thanx
Gopal Prabhakaran

--
"Sucess Comes To Those Who Dare To Dream"

Thanx
Gopal Prabhakaran
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top