Home > Net >  Get all the name of the thread
Get all the name of the thread

Time:10-24

The great god, how to get the name of all threads in c #, the following code to obtain the name "TestName", thank you very much!

 
New Thread (()=& gt;
{
Thread. The CurrentThread. Name="TestName";
For (int I=0; I & lt; 10; I++)
{
Console. WriteLine (I);
Console. WriteLine (" a "+ Thread. CurrentThread. Name);
}
}). The Start ();

CodePudding user response:

 using System; 
Using System. Diagnostics;

The namespace ConsoleApp1
{
Class Program
{
The static void Main (string [] args)
{
Foreach (Process p in the Process. GetProcesses ())
{
Console. WriteLine (p.P rocessName);
}
The Console. The Read ();
}
}
}

CodePudding user response:

ThreadPool?

CodePudding user response:

1/f, reference The kei ℡ response:
 using System; 
Using System. Diagnostics;

The namespace ConsoleApp1
{
Class Program
{
The static void Main (string [] args)
{
Foreach (Process p in the Process. GetProcesses ())
{
Console. WriteLine (p.P rocessName);
}
The Console. The Read ();
}
}
}

This is the process name

CodePudding user response:

Var the processes=Process. GetProcesses ();

We don't know what do you want to ask what, can only give a the first, this is all the processes for current system, want to know the thread, is, of course, look for the process, get the thread on the traversal process

CodePudding user response:

refer to the second floor strife013 response:
ThreadPool?

yes

CodePudding user response:

reference 4 floor wanghui0380 response:
var the processes=Process. GetProcesses ();

We don't know what do you want to ask what, can only give a the first, this is all the processes for current system, want to know the thread, is, of course, look for the process, get a thread in the traversal process

I want to iterate through the current process (this process is under my development program) threads, thread name all the process, the following code name "TestName"

 new Thread (()=& gt; 
{
Thread. The CurrentThread. Name="TestName";
For (int I=0; I & lt; 10; I++)
{
Console. WriteLine (I);
Console. WriteLine (" a "+ Thread. CurrentThread. Name);
}
}). The Start ();
  •  Tags:  
  • C#
  • Related