获取当前线程id

转:https://www.cnblogs.com/comsky/p/6020327.html

 

如果获得当前进程的Id用:

Process[] processes = Process.GetProcesses(); 
foreach(Process process in processes) 

if(process.ProcessName == "进程名" 

MessageBox.Show(process.Id); 

}

Process processes   =Process.GetCurrentProcess

processes.id获得当前进程的ID

如果获得当前线程的ID用:

Thread.CurrentThread.ManagedThreadId.ToString() (推荐)

AppDomain.GetCurrentThreadId().ToString()


posted @ 2018-05-21 15:46  朱小勇  阅读(9169)  评论(0编辑  收藏  举报