C# 多线程数组,如何得到当前线程的名字?

sharpidea 2007-11-26 10:56:30
public Thread[] thStep;
public int thStepCount=5;

private void button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < thStepCount; i++)
{
thStep[i] = new Thread(startWebBrower);
thStep[i].Name = i.ToString();
thStep[i].Start();
}
}
private void startWebBrower()
{
//如何得到当前线程的名字?
}
...全文
2158 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
deknight 2010-05-21
  • 打赏
  • 举报
回复
晕,原来是挖坟的
兔子-顾问 2010-05-21
  • 打赏
  • 举报
回复
4楼。你真是在考古……
2007年的帖子你翻出来回答了。而且居然楼主还没结贴。
deknight 2010-05-21
  • 打赏
  • 举报
回复
en,thread.name
饅頭 2010-05-21
  • 打赏
  • 举报
回复
当前线程名: Thread.CurrentThread.Name
echoxue 2008-10-28
  • 打赏
  • 举报
回复
lz
thStep[i] = new Thread(startWebBrower);
这句能编译过吗?
应该这样吧:


int thStepCount=5;
Thread[] thStep = new Thread[thStepCount]
private void button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < thStepCount; i++)
{
thStep[i] = new Thread(startWebBrower);
thStep[i].Name = i.ToString();
thStep[i].Start();
}
}
private void startWebBrower()
{
//如何得到当前线程的名字?
}
sharpidea 2007-11-26
  • 打赏
  • 举报
回复
yes , u are so nice
thinkingforever 2007-11-26
  • 打赏
  • 举报
回复
System.Threading.Thread.CurrentThread.Name

110,535

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧